Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c1b4b0f

Browse filesBrowse files
csabellamiss-islington
authored andcommitted
bpo-22703: IDLE: Improve Code Context and Zoom Height menu labels (GH-11214)
The Code Context menu label now toggles between Show/Hide Code Context. The Zoom Height menu now toggles between Zoom/Restore Height. Zoom Height has moved from the Window menu to the Options menu. https://bugs.python.org/issue22703
1 parent 87667c5 commit c1b4b0f
Copy full SHA for c1b4b0f

File tree

Expand file treeCollapse file tree

8 files changed

+39
-11
lines changed
Filter options
Expand file treeCollapse file tree

8 files changed

+39
-11
lines changed

‎Doc/library/idle.rst

Copy file name to clipboardExpand all lines: Doc/library/idle.rst
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -275,21 +275,21 @@ Configure IDLE
275275
menu. For more, see
276276
:ref:`Setting preferences <preferences>` under Help and preferences.
277277

278-
Code Context (toggle)(Editor Window only)
278+
Zoom/Restore Height
279+
Toggles the window between normal size and maximum height. The initial size
280+
defaults to 40 lines by 80 chars unless changed on the General tab of the
281+
Configure IDLE dialog.
282+
283+
Show/Hide Code Context (Editor Window only)
279284
Open a pane at the top of the edit window which shows the block context
280285
of the code which has scrolled above the top of the window. See
281286
:ref:`Code Context <code-context>` in the Editing and Navigation section below.
282287

283288
Window menu (Shell and Editor)
284289
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
285290

286-
Zoom Height
287-
Toggles the window between normal size and maximum height. The initial size
288-
defaults to 40 lines by 80 chars unless changed on the General tab of the
289-
Configure IDLE dialog.
290-
291-
The rest of this menu lists the names of all open windows; select one to bring
292-
it to the foreground (deiconifying it if necessary).
291+
Lists the names of all open windows; select one to bring it to the foreground
292+
(deiconifying it if necessary).
293293

294294
Help menu (Shell and Editor)
295295
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

‎Lib/idlelib/NEWS.txt

Copy file name to clipboardExpand all lines: Lib/idlelib/NEWS.txt
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ Released on 2019-10-20?
33
======================================
44

55

6+
bpo-22703: Improve the Code Context and Zoom Height menu labels.
7+
The Code Context menu label now toggles between Show/Hide Code Context.
8+
The Zoom Height menu now toggles between Zoom/Restore Height.
9+
Zoom Height has moved from the Window menu to the Options menu.
10+
611
bpo-35521: Document the editor code context feature.
712
Add some internal references within the IDLE doc.
813

‎Lib/idlelib/codecontext.py

Copy file name to clipboardExpand all lines: Lib/idlelib/codecontext.py
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,13 @@ def toggle_code_context_event(self, event=None):
122122
# thus ensuring that it will appear directly above text_frame.
123123
self.context.pack(side=TOP, fill=X, expand=False,
124124
before=self.editwin.text_frame)
125+
menu_status = 'Hide'
125126
else:
126127
self.context.destroy()
127128
self.context = None
129+
menu_status = 'Show'
130+
self.editwin.update_menu_label(menu='options', index='* Code Context',
131+
label=f'{menu_status} Code Context')
128132
return "break"
129133

130134
def get_context(self, new_topvisible, stopline=1, stopindent=0):

‎Lib/idlelib/editor.py

Copy file name to clipboardExpand all lines: Lib/idlelib/editor.py
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,11 @@ def postwindowsmenu(self):
446446
menu.delete(self.wmenu_end+1, end)
447447
window.add_windows_to_menu(menu)
448448

449+
def update_menu_label(self, menu, index, label):
450+
"Update label for menu item at index ."
451+
menuitem = self.menudict[menu]
452+
menuitem.entryconfig(index, label=label)
453+
449454
def handle_yview(self, event, *args):
450455
"Handle scrollbar."
451456
if event == 'moveto':

‎Lib/idlelib/idle_test/test_codecontext.py

Copy file name to clipboardExpand all lines: Lib/idlelib/idle_test/test_codecontext.py
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ def __init__(self, root, frame, text):
4040
self.top = root
4141
self.text_frame = frame
4242
self.text = text
43+
self.label = ''
44+
45+
def update_menu_label(self, **kwargs):
46+
self.label = kwargs['label']
4347

4448

4549
class CodeContextTest(unittest.TestCase):
@@ -127,10 +131,12 @@ def test_toggle_code_context_event(self):
127131
eq(cc.context['fg'], cc.colors['foreground'])
128132
eq(cc.context['bg'], cc.colors['background'])
129133
eq(cc.context.get('1.0', 'end-1c'), '')
134+
eq(cc.editwin.label, 'Hide Code Context')
130135

131136
# Toggle off.
132137
eq(toggle(), 'break')
133138
self.assertIsNone(cc.context)
139+
eq(cc.editwin.label, 'Show Code Context')
134140

135141
def test_get_context(self):
136142
eq = self.assertEqual

‎Lib/idlelib/mainmenu.py

Copy file name to clipboardExpand all lines: Lib/idlelib/mainmenu.py
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,12 @@
9494

9595
('options', [
9696
('Configure _IDLE', '<<open-config-dialog>>'),
97-
('_Code Context', '<<toggle-code-context>>'),
97+
None,
98+
('Show _Code Context', '<<toggle-code-context>>'),
99+
('Zoom Height', '<<zoom-height>>'),
98100
]),
99101

100102
('window', [
101-
('Zoom Height', '<<zoom-height>>'),
102103
]),
103104

104105
('help', [

‎Lib/idlelib/zoomheight.py

Copy file name to clipboardExpand all lines: Lib/idlelib/zoomheight.py
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ def __init__(self, editwin):
1313

1414
def zoom_height_event(self, event=None):
1515
top = self.editwin.top
16-
zoom_height(top)
16+
zoomed = zoom_height(top)
17+
menu_status = 'Restore' if zoomed else 'Zoom'
18+
self.editwin.update_menu_label(menu='options', index='* Height',
19+
label=f'{menu_status} Height')
1720
return "break"
1821

1922

@@ -46,6 +49,7 @@ def zoom_height(top):
4649
else:
4750
newgeom = "%dx%d+%d+%d" % (width, newheight, x, newy)
4851
top.wm_geometry(newgeom)
52+
return newgeom != ""
4953

5054

5155
if __name__ == "__main__":
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The Code Context menu label now toggles between Show/Hide Code Context.
2+
The Zoom Height menu now toggles between Zoom/Restore Height.
3+
Zoom Height has moved from the Window menu to the Options menu.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.