-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlitehtml-txt.py
More file actions
executable file
·53 lines (43 loc) · 1.45 KB
/
Copy pathlitehtml-txt.py
File metadata and controls
executable file
·53 lines (43 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env vpython3
import sys
import wx
import logme
from litehtmlpy import litehtmltxt, litehtmlpy
class Dokument(litehtmltxt.document_container):
def __init__(self, fname):
super().__init__()
self.fname = fname
def pt_to_px(self, pt):
return litehtmlpy.pixel_float_t(1)
#return litehtmlpy.pixel_float_t(pt)
def Run(self):
with open(self.fname, 'rt') as fp:
html = fp.read()
doc = litehtmlpy.fromString(self, html, None, None)
try:
doc.render(self.size.width, litehtmlpy.render_all)
self.size = litehtmlpy.size(int(self.size.width.value), int(doc.height().value))
self.reset()
print('DOC:', 'w=', doc.width().value, 'h=', doc.height().value)
clip = litehtmlpy.position(0, 0, int(doc.width().value), int(doc.height().value))
doc.draw(0, litehtmlpy.pixel_float_t(0), litehtmlpy.pixel_float_t(0), clip)
for y in self.dc.lines():
line = self.dc.line(y)
print(line)
for line in sorted(self.dc._lines.keys())[:5]:
print(self.dc._lines[line])
finally:
self.SetDC(None)
del doc
class Main:
def demo(self):
if len(sys.argv) > 1:
fname = sys.argv[1]
else:
fname = 'demo.html'
cls = Dokument(fname)
cls.Run()
def main():
app = Main()
app.demo()
main()