Configure tags and feed file to parser.
(self, parent, filename)
| 167 | class HelpText(Text): |
| 168 | "Display help.html." |
| 169 | def __init__(self, parent, filename): |
| 170 | "Configure tags and feed file to parser." |
| 171 | uwide = idleConf.GetOption('main', 'EditorWindow', 'width', type='int') |
| 172 | uhigh = idleConf.GetOption('main', 'EditorWindow', 'height', type='int') |
| 173 | uhigh = 3 * uhigh // 4 # Lines average 4/3 of editor line height. |
| 174 | Text.__init__(self, parent, wrap='word', highlightthickness=0, |
| 175 | padx=5, borderwidth=0, width=uwide, height=uhigh) |
| 176 | |
| 177 | normalfont = self.findfont(['TkDefaultFont', 'arial', 'helvetica']) |
| 178 | fixedfont = self.findfont(['TkFixedFont', 'monaco', 'courier']) |
| 179 | color_config(self) |
| 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)) |
| 186 | preback = self['selectbackground'] |
| 187 | self.tag_configure('preblock', font=(fixedfont, 10), lmargin1=25, |
| 188 | background=preback) |
| 189 | self.tag_configure('l1', lmargin1=25, lmargin2=25) |
| 190 | self.tag_configure('l2', lmargin1=50, lmargin2=50) |
| 191 | self.tag_configure('l3', lmargin1=75, lmargin2=75) |
| 192 | self.tag_configure('l4', lmargin1=100, lmargin2=100) |
| 193 | |
| 194 | self.parser = HelpParser(self) |
| 195 | with open(filename, encoding='utf-8') as f: |
| 196 | contents = f.read() |
| 197 | self.parser.feed(contents) |
| 198 | self['state'] = 'disabled' |
| 199 | |
| 200 | def findfont(self, names): |
| 201 | "Return name of first font family derived from names." |
no test coverage detected