Skip to content
13 changes: 9 additions & 4 deletions Lib/idlelib/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def __init__(self, canvas, parent, item):
self.selected = False
self.children = []
self.x = self.y = None
self.dy = 0
self.iconimages = {} # cache of PhotoImage instances for icons

def destroy(self):
Expand Down Expand Up @@ -199,23 +200,22 @@ def update(self):

def draw(self, x, y):
# XXX This hard-codes too many geometry constants!
dy = 20
self.x, self.y = x, y
self.drawicon()
self.drawtext()
if self.state != 'expanded':
return y + dy
return y + self.dy
# draw children
if not self.children:
sublist = self.item._GetSubList()
if not sublist:
# _IsExpandable() was mistaken; that's allowed
return y+17
return y + self.dy
for item in sublist:
child = self.__class__(self.canvas, self, item)
self.children.append(child)
cx = x+20
cy = y + dy
cy = y + self.dy
cylast = 0
for child in self.children:
cylast = cy
Expand Down Expand Up @@ -289,6 +289,11 @@ def drawtext(self):
self.label.bind("<Button-4>", lambda e: wheel_event(e, self.canvas))
self.label.bind("<Button-5>", lambda e: wheel_event(e, self.canvas))
self.text_id = id
if self.dy == 0:
# The first row doesn't matter what the dy is, just measure its
# size to get the value of the subsequent dy
coords = self.canvas.bbox(id)
self.dy = coords[3] - coords[1]

def select_or_edit(self, event=None):
if self.selected and self.item.IsEditable():
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed the wrong vertical spacing of the Path Browser of IDLE.
Loading