Configure tags and feed file to parser.
(self, parent, filename)
| 168 | class HelpText(Text): |
| 169 | "Display help.html." |
| 170 | def __init__(self, parent, filename): |
| 171 | "Configure tags and feed file to parser." |
| 172 | uwide = idleConf.GetOption('main', 'EditorWindow', 'width', type='int') |
| 173 | uhigh = idleConf.GetOption('main', 'EditorWindow', 'height', type='int') |
| 174 | uhigh = 3 * uhigh // 4 # Lines average 4/3 of editor line height. |
| 175 | Text.__init__(self, parent, wrap='word', highlightthickness=0, |
| 176 | padx=5, borderwidth=0, width=uwide, height=uhigh) |
| 177 | |
| 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, |
| 187 | borderwidth=1, relief='solid', background='#eeffcc') |
| 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) |
| 192 | |
| 193 | self.parser = HelpParser(self) |
| 194 | with open(filename, encoding='utf-8') as f: |
| 195 | contents = f.read() |
| 196 | self.parser.feed(contents) |
| 197 | self['state'] = 'disabled' |
| 198 | |
| 199 | def findfont(self, names): |
| 200 | "Return name of first font family derived from names." |
no test coverage detected