MCPcopy Index your code
hub / github.com/python/cpython / HelpText

Class HelpText

Lib/idlelib/help.py:167–208  ·  view source on GitHub ↗

Display help.html.

Source from the content-addressed store, hash-verified

165
166
167class 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."
202 for name in names:
203 if name.lower() in (x.lower() for x in tkfont.names(root=self)):
204 font = tkfont.Font(name=name, exists=True, root=self)
205 return font.actual()['family']
206 elif name.lower() in (x.lower()
207 for x in tkfont.families(root=self)):
208 return name
209
210
211class HelpFrame(Frame):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…