MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / HelpText

Class HelpText

tools/python-3.11.9-amd64/Lib/idlelib/help.py:168–207  ·  view source on GitHub ↗

Display help.html.

Source from the content-addressed store, hash-verified

166
167
168class 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."
201 for name in 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)
204 return font.actual()['family']
205 elif name.lower() in (x.lower()
206 for x in tkfont.families(root=self)):
207 return name
208
209
210class HelpFrame(Frame):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected