Added 'list_only' option (and modified 'run()' to respect it).
[python/dscho.git] / Demo / tkinter / www / tkfmt.py
blobadbb002eb15384b1d2d58c3f3856ef4e9ecb728e
1 # Tk backend -- unfinished
3 debug = 0
5 from fmt import *
7 class TkFormatter:
9 def __init__(self, text):
10 self.text = text # The text widget to draw in
11 self.nospace = 1
12 self.blanklines = 0
13 self.font = ''
15 # Methods called by htmllib.FormattingParser:
17 def setfont(self, font):
18 if 1 or debug: print "setfont(%s)" % `font`
19 self.font = font
21 def resetfont(self):
22 if debug: print "resetfont()"
23 self.font = ''
25 def flush(self):
26 if debug: print "flush()"
27 self.needvspace(1)
29 def setleftindent(self, n):
30 if debug: print "setleftindent(%d)" % n
32 def needvspace(self, n):
33 if debug: print "needvspace(%d)" % n
34 self.blanklines = max(n, self.blanklines)
35 self.nospace = 1
37 def addword(self, word, nspaces):
38 if debug: print "addword(%s, %d)" % (`word`, nspaces)
39 if self.nospace and not word:
40 return
41 if self.blanklines > 0:
42 word = '\n'*self.blanklines + word
43 self.blanklines = 0
44 self.nospace = 0
45 here = self.text.index('end')
46 self.text.insert('end', word + nspaces*' ')
47 if not self.font:
48 self.tag_remo
50 def setjust(self, c):
51 if debug: print "setjust(%s)" % `c`
53 def bgn_anchor(self):
54 if debug: print "bgn_anchor()"
56 def end_anchor(self):
57 if debug: print "end_anchor()"
59 def hrule(self):
60 if debug: print "hrule()"
61 self.flush()
62 self.addword('_'*60, 0)
63 self.flush()