Skip to content

Commit 79b4c9d

Browse files
miss-islingtonXiaokang2022terryjreedy
authored
[3.12] gh-122392: IDLE - Fix overlapping lines in browsers (GH-122392) (GH-124975) (#125062)
gh-122392: IDLE - Fix overlapping lines in browsers (GH-122392) (GH-124975) Increase currently inadequate vertical spacing for the IDLE browsers (path, module, and stack) on high-resolution monitors. --------- (cherry picked from commit c5df1cb) Co-authored-by: Zhikang Yan <[email protected]> Co-authored-by: Terry Jan Reedy <[email protected]>
1 parent a01970d commit 79b4c9d

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

Lib/idlelib/tree.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ def wheel_event(event, widget=None):
8383

8484
class TreeNode:
8585

86+
dy = 0
87+
8688
def __init__(self, canvas, parent, item):
8789
self.canvas = canvas
8890
self.parent = parent
@@ -199,23 +201,22 @@ def update(self):
199201

200202
def draw(self, x, y):
201203
# XXX This hard-codes too many geometry constants!
202-
dy = 20
203204
self.x, self.y = x, y
204205
self.drawicon()
205206
self.drawtext()
206207
if self.state != 'expanded':
207-
return y + dy
208+
return y + TreeNode.dy
208209
# draw children
209210
if not self.children:
210211
sublist = self.item._GetSubList()
211212
if not sublist:
212213
# _IsExpandable() was mistaken; that's allowed
213-
return y+17
214+
return y + TreeNode.dy
214215
for item in sublist:
215216
child = self.__class__(self.canvas, self, item)
216217
self.children.append(child)
217218
cx = x+20
218-
cy = y + dy
219+
cy = y + TreeNode.dy
219220
cylast = 0
220221
for child in self.children:
221222
cylast = cy
@@ -289,6 +290,11 @@ def drawtext(self):
289290
self.label.bind("<Button-4>", lambda e: wheel_event(e, self.canvas))
290291
self.label.bind("<Button-5>", lambda e: wheel_event(e, self.canvas))
291292
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)
292298

293299
def select_or_edit(self, event=None):
294300
if self.selected and self.item.IsEditable():
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Increase currently inadequate vertical spacing for the IDLE browsers (path,
2+
module, and stack) on high-resolution monitors.

0 commit comments

Comments
 (0)