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

Method drawtext

Lib/idlelib/tree.py:256–297  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

254 self.canvas.tag_bind(id, "<Double-1>", self.flip)
255
256 def drawtext(self):
257 textx = self.x+20-1
258 texty = self.y-4
259 labeltext = self.item.GetLabelText()
260 if labeltext:
261 id = self.canvas.create_text(textx, texty, anchor="nw",
262 text=labeltext)
263 self.canvas.tag_bind(id, "<1>", self.select)
264 self.canvas.tag_bind(id, "<Double-1>", self.flip)
265 x0, y0, x1, y1 = self.canvas.bbox(id)
266 textx = max(x1, 200) + 10
267 text = self.item.GetText() or "<no text>"
268 try:
269 self.entry
270 except AttributeError:
271 pass
272 else:
273 self.edit_finish()
274 try:
275 self.label
276 except AttributeError:
277 # padding carefully selected (on Windows) to match Entry widget:
278 self.label = Label(self.canvas, text=text, bd=0, padx=2, pady=2)
279 theme = idleConf.CurrentTheme()
280 if self.selected:
281 self.label.configure(idleConf.GetHighlight(theme, 'hilite'))
282 else:
283 self.label.configure(idleConf.GetHighlight(theme, 'normal'))
284 id = self.canvas.create_window(textx, texty,
285 anchor="nw", window=self.label)
286 self.label.bind("<1>", self.select_or_edit)
287 self.label.bind("<Double-1>", self.flip)
288 self.label.bind("<MouseWheel>", lambda e: wheel_event(e, self.canvas))
289 if self.label._windowingsystem == 'x11':
290 self.label.bind("<Button-4>", lambda e: wheel_event(e, self.canvas))
291 self.label.bind("<Button-5>", lambda e: wheel_event(e, self.canvas))
292 self.text_id = id
293 if TreeNode.dy == 0:
294 # The first row doesn't matter what the dy is, just measure its
295 # size to get the value of the subsequent dy
296 coords = self.canvas.bbox(id)
297 TreeNode.dy = max(20, coords[3] - coords[1] - 3)
298
299 def select_or_edit(self, event=None):
300 if self.selected and self.item.IsEditable():

Callers 5

selectMethod · 0.95
deselectMethod · 0.95
drawMethod · 0.95
edit_finishMethod · 0.95
edit_cancelMethod · 0.95

Calls 13

edit_finishMethod · 0.95
wheel_eventFunction · 0.85
create_textMethod · 0.80
CurrentThemeMethod · 0.80
GetHighlightMethod · 0.80
create_windowMethod · 0.80
LabelClass · 0.50
GetLabelTextMethod · 0.45
tag_bindMethod · 0.45
bboxMethod · 0.45
GetTextMethod · 0.45
configureMethod · 0.45

Tested by

no test coverage detected