From d39b32fc6578d7d4c19b15913d1de1b3bec8eaf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=BA=B72022?= <2951256653@qq.com> Date: Fri, 4 Oct 2024 23:02:21 +0800 Subject: [PATCH 1/6] gh-122392: Fix the wrong size of the Path Browser vertical spacing for IDLE (#122392) --- Lib/idlelib/tree.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Lib/idlelib/tree.py b/Lib/idlelib/tree.py index 0726d7e23660f6..3410ce30615be2 100644 --- a/Lib/idlelib/tree.py +++ b/Lib/idlelib/tree.py @@ -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): @@ -199,12 +200,11 @@ 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() @@ -215,7 +215,7 @@ def draw(self, x, y): 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 @@ -289,6 +289,11 @@ def drawtext(self): self.label.bind("", lambda e: wheel_event(e, self.canvas)) self.label.bind("", 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(): From a9f146b763d74528f06e7288e93f7d22abf95e5e Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Fri, 4 Oct 2024 15:34:34 +0000 Subject: [PATCH 2/6] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/IDLE/2024-10-04-15-34-34.gh-issue-122392.V8K3w2.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/IDLE/2024-10-04-15-34-34.gh-issue-122392.V8K3w2.rst diff --git a/Misc/NEWS.d/next/IDLE/2024-10-04-15-34-34.gh-issue-122392.V8K3w2.rst b/Misc/NEWS.d/next/IDLE/2024-10-04-15-34-34.gh-issue-122392.V8K3w2.rst new file mode 100644 index 00000000000000..6f2c35ebeade70 --- /dev/null +++ b/Misc/NEWS.d/next/IDLE/2024-10-04-15-34-34.gh-issue-122392.V8K3w2.rst @@ -0,0 +1 @@ +Fixed the wrong vertical spacing of the Path Browser of IDLE. From b4c3904c43bea1494b733577b015dc23fa7f0ec5 Mon Sep 17 00:00:00 2001 From: Xiaokang2022 <2951256653@qq.com> Date: Sat, 5 Oct 2024 00:23:26 +0800 Subject: [PATCH 3/6] Fix a case where `_IsExpandable()` was mistaken would still show incorrectly --- Lib/idlelib/tree.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/idlelib/tree.py b/Lib/idlelib/tree.py index 3410ce30615be2..ed1094dcce6e1c 100644 --- a/Lib/idlelib/tree.py +++ b/Lib/idlelib/tree.py @@ -210,7 +210,7 @@ def draw(self, x, y): 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) From 216a84eebdf33ad53c73b5b54b22b9568ccd957e Mon Sep 17 00:00:00 2001 From: Xiaokang2022 <2951256653@qq.com> Date: Sat, 5 Oct 2024 03:23:42 +0800 Subject: [PATCH 4/6] Made the requested changes --- Lib/idlelib/tree.py | 13 +++++++------ .../2024-10-04-15-34-34.gh-issue-122392.V8K3w2.rst | 3 ++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Lib/idlelib/tree.py b/Lib/idlelib/tree.py index ed1094dcce6e1c..57a5bbf77705d0 100644 --- a/Lib/idlelib/tree.py +++ b/Lib/idlelib/tree.py @@ -83,6 +83,8 @@ def wheel_event(event, widget=None): class TreeNode: + dy = 0 + def __init__(self, canvas, parent, item): self.canvas = canvas self.parent = parent @@ -91,7 +93,6 @@ 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): @@ -204,18 +205,18 @@ def draw(self, x, y): self.drawicon() self.drawtext() if self.state != 'expanded': - return y + self.dy + return y + TreeNode.dy # draw children if not self.children: sublist = self.item._GetSubList() if not sublist: # _IsExpandable() was mistaken; that's allowed - return y + self.dy + return y + TreeNode.dy - 3 for item in sublist: child = self.__class__(self.canvas, self, item) self.children.append(child) cx = x+20 - cy = y + self.dy + cy = y + TreeNode.dy cylast = 0 for child in self.children: cylast = cy @@ -289,11 +290,11 @@ def drawtext(self): self.label.bind("", lambda e: wheel_event(e, self.canvas)) self.label.bind("", lambda e: wheel_event(e, self.canvas)) self.text_id = id - if self.dy == 0: + if TreeNode.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] + TreeNode.dy = max(20, coords[3] - coords[1] - 3) def select_or_edit(self, event=None): if self.selected and self.item.IsEditable(): diff --git a/Misc/NEWS.d/next/IDLE/2024-10-04-15-34-34.gh-issue-122392.V8K3w2.rst b/Misc/NEWS.d/next/IDLE/2024-10-04-15-34-34.gh-issue-122392.V8K3w2.rst index 6f2c35ebeade70..c93a6fb90e1bc0 100644 --- a/Misc/NEWS.d/next/IDLE/2024-10-04-15-34-34.gh-issue-122392.V8K3w2.rst +++ b/Misc/NEWS.d/next/IDLE/2024-10-04-15-34-34.gh-issue-122392.V8K3w2.rst @@ -1 +1,2 @@ -Fixed the wrong vertical spacing of the Path Browser of IDLE. +Increase currently inadequate vertical spacing for the IDLE browsers (path, +module, and stack) on high-resolution monitors. From 6702185ebc1f174290dbd0c77bda08cec0508cca Mon Sep 17 00:00:00 2001 From: Xiaokang2022 <2951256653@qq.com> Date: Sat, 5 Oct 2024 03:31:56 +0800 Subject: [PATCH 5/6] Remove a redundant whitespace character --- .../next/IDLE/2024-10-04-15-34-34.gh-issue-122392.V8K3w2.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/IDLE/2024-10-04-15-34-34.gh-issue-122392.V8K3w2.rst b/Misc/NEWS.d/next/IDLE/2024-10-04-15-34-34.gh-issue-122392.V8K3w2.rst index c93a6fb90e1bc0..541f6212794ef2 100644 --- a/Misc/NEWS.d/next/IDLE/2024-10-04-15-34-34.gh-issue-122392.V8K3w2.rst +++ b/Misc/NEWS.d/next/IDLE/2024-10-04-15-34-34.gh-issue-122392.V8K3w2.rst @@ -1,2 +1,2 @@ -Increase currently inadequate vertical spacing for the IDLE browsers (path, +Increase currently inadequate vertical spacing for the IDLE browsers (path, module, and stack) on high-resolution monitors. From 3a6f6e581c73bf2051d23c113c72f8d82420982f Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Sat, 5 Oct 2024 14:00:31 -0400 Subject: [PATCH 6/6] Update Lib/idlelib/tree.py --- Lib/idlelib/tree.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/idlelib/tree.py b/Lib/idlelib/tree.py index 57a5bbf77705d0..182ce7189614da 100644 --- a/Lib/idlelib/tree.py +++ b/Lib/idlelib/tree.py @@ -211,7 +211,7 @@ def draw(self, x, y): sublist = self.item._GetSubList() if not sublist: # _IsExpandable() was mistaken; that's allowed - return y + TreeNode.dy - 3 + return y + TreeNode.dy for item in sublist: child = self.__class__(self.canvas, self, item) self.children.append(child)