Lines Matching refs:self

51     def __init__(self, text):
52 HTMLParser.__init__(self, convert_charrefs=True)
53 self.text = text # Text widget we're rendering into.
54 self.tags = '' # Current block level text tags to apply.
55 self.chartags = '' # Current character level text tags.
56 self.show = False # Exclude html page navigation.
57 self.hdrlink = False # Exclude html header links.
58 self.level = 0 # Track indentation level.
59 self.pre = False # Displaying preformatted text?
60 self.hprefix = '' # Heading prefix (like '25.5'?) to remove.
61 self.nested_dl = False # In a nested <dl>?
62 self.simplelist = False # In a simple list (no double spacing)?
63 self.toc = [] # Pair headers with text indexes for toc.
64 self.header = '' # Text within header tags for toc.
65 self.prevtag = None # Previous tag info (opener?, tag).
67 def indent(self, amt=1):
69 self.level += amt
70 self.tags = '' if self.level == 0 else 'l'+str(self.level)
72 def handle_starttag(self, tag, attrs):
80 self.show = True # Start main content.
82 self.show = False # End main content.
83 elif tag == 'p' and self.prevtag and not self.prevtag[0]:
86 lastline = self.text.get('end-1c linestart', 'end-1c')
89 self.chartags = 'pre'
91 self.chartags = 'em'
93 self.chartags = 'em'
97 self.simplelist = True
99 self.simplelist = False
100 self.indent()
102 if self.level > 0:
103 self.nested_dl = True
105 s = '\n* ' if self.simplelist else '\n\n* '
107 s = '\n\n' if not self.nested_dl else '\n' # Avoid extra line.
108 self.nested_dl = False
110 self.indent()
113 self.pre = True
114 if self.show:
115 self.text.insert('end', '\n\n')
116 self.tags = 'preblock'
118 self.hdrlink = True
120 self.tags = tag
122 if self.show:
123 self.header = ''
124 self.text.insert('end', '\n\n')
125 self.tags = tag
126 if self.show:
127 self.text.insert('end', s, (self.tags, self.chartags))
128 self.prevtag = (True, tag)
130 def handle_endtag(self, tag):
133 assert self.level == 0
134 if self.show:
138 self.toc.append((indent+self.header, self.text.index('insert')))
139 self.tags = ''
141 self.chartags = ''
143 self.hdrlink = False
145 self.pre = False
146 self.tags = ''
148 self.indent(-1)
149 self.prevtag = (False, tag)
151 def handle_data(self, data):
153 if self.show and not self.hdrlink:
154 d = data if self.pre else data.replace('\n', ' ')
155 if self.tags == 'h1':
157 self.hprefix = d[0:d.index(' ')]
159 self.hprefix = ''
160 if self.tags in ['h1', 'h2', 'h3']:
161 if (self.hprefix != '' and
162 d[0:len(self.hprefix)] == self.hprefix):
163 d = d[len(self.hprefix):]
164 self.header += d.strip()
165 self.text.insert('end', d, (self.tags, self.chartags))
170 def __init__(self, parent, filename):
175 Text.__init__(self, parent, wrap='word', highlightthickness=0,
178 normalfont = self.findfont(['TkDefaultFont', 'arial', 'helvetica'])
179 fixedfont = self.findfont(['TkFixedFont', 'monaco', 'courier'])
180 self['font'] = (normalfont, 12)
181 self.tag_configure('em', font=(normalfont, 12, 'italic'))
182 self.tag_configure('h1', font=(normalfont, 20, 'bold'))
183 self.tag_configure('h2', font=(normalfont, 18, 'bold'))
184 self.tag_configure('h3', font=(normalfont, 15, 'bold'))
185 self.tag_configure('pre', font=(fixedfont, 12), background='#f6f6ff')
186 self.tag_configure('preblock', font=(fixedfont, 10), lmargin1=25,
188 self.tag_configure('l1', lmargin1=25, lmargin2=25)
189 self.tag_configure('l2', lmargin1=50, lmargin2=50)
190 self.tag_configure('l3', lmargin1=75, lmargin2=75)
191 self.tag_configure('l4', lmargin1=100, lmargin2=100)
193 self.parser = HelpParser(self)
196 self.parser.feed(contents)
197 self['state'] = 'disabled'
199 def findfont(self, names):
202 if name.lower() in (x.lower() for x in tkfont.names(root=self)):
203 font = tkfont.Font(name=name, exists=True, root=self)
206 for x in tkfont.families(root=self)):
212 def __init__(self, parent, filename):
213 Frame.__init__(self, parent)
214 self.text = text = HelpText(self, filename)
215 self.style = Style(parent)
216 self['style'] = 'helpframe.TFrame'
217 self.style.configure('helpframe.TFrame', background=text['background'])
218 self.toc = toc = self.toc_menu(text)
219 self.scroll = scroll = Scrollbar(self, command=text.yview)
222 self.rowconfigure(0, weight=1)
223 self.columnconfigure(1, weight=1) # Only expand the text widget.
228 def toc_menu(self, text):
230 toc = Menubutton(self, text='TOC')
240 def __init__(self, parent, filename, title):
241 Toplevel.__init__(self, parent)
242 self.wm_title(title)
243 self.protocol("WM_DELETE_WINDOW", self.destroy)
244 HelpFrame(self, filename).grid(column=0, row=0, sticky='nsew')
245 self.grid_columnconfigure(0, weight=1)
246 self.grid_rowconfigure(0, weight=1)