From 31a8f46b4725535304556163bee5c2f6a312d8a9 Mon Sep 17 00:00:00 2001 From: E-Paine <63801254+E-Paine@users.noreply.github.com> Date: Thu, 30 Apr 2020 15:56:19 +0100 Subject: [PATCH 1/6] IDLE support for maximising editor windows on load Changes as per PEP 23937 --- Lib/idlelib/config-main.def | 1 + Lib/idlelib/configdialog.py | 17 ++++++++++++++++- Lib/idlelib/editor.py | 2 ++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Lib/idlelib/config-main.def b/Lib/idlelib/config-main.def index 28ae94161d5c035..fee59212891c835 100644 --- a/Lib/idlelib/config-main.def +++ b/Lib/idlelib/config-main.def @@ -57,6 +57,7 @@ print-command-win=start /min notepad /p %%s delete-exitfunc= 1 [EditorWindow] +max= 0 width= 80 height= 40 cursor-blink= 1 diff --git a/Lib/idlelib/configdialog.py b/Lib/idlelib/configdialog.py index 82596498d346111..50d96b446582021 100644 --- a/Lib/idlelib/configdialog.py +++ b/Lib/idlelib/configdialog.py @@ -1864,6 +1864,8 @@ def create_page_general(self): # Integer values need StringVar because int('') raises. self.startup_edit = tracers.add( IntVar(self), ('main', 'General', 'editor-on-startup')) + self.win_max = tracers.add( + BooleanVar(self), ('main', 'EditorWindow', 'max')) self.win_width = tracers.add( StringVar(self), ('main', 'EditorWindow', 'width')) self.win_height = tracers.add( @@ -1915,6 +1917,8 @@ def create_page_general(self): frame_win_size = Frame(frame_window, borderwidth=0) win_size_title = Label( frame_win_size, text='Initial Window Size (in characters)') + win_max_title = Checkbutton(frame_win_size, text='Maximised', variable=self.win_max) + self.win_max.trace("w", lambda a, b, c: self.toggle_entry_mode()) win_width_title = Label(frame_win_size, text='Width') self.win_width_int = Entry( frame_win_size, textvariable=self.win_width, width=3, @@ -2030,7 +2034,8 @@ def create_page_general(self): self.startup_editor_on.pack(side=RIGHT, anchor=W, padx=5, pady=5) # frame_win_size. frame_win_size.pack(side=TOP, padx=5, pady=0, fill=X) - win_size_title.pack(side=LEFT, anchor=W, padx=5, pady=5) + win_size_title.pack(side=LEFT, anchor=NW, padx=5, pady=5) + win_max_title.pack(side=TOP, anchor=E, padx=10, pady=5) self.win_height_int.pack(side=RIGHT, anchor=E, padx=10, pady=5) win_height_title.pack(side=RIGHT, anchor=E, pady=5) self.win_width_int.pack(side=RIGHT, anchor=E, padx=10, pady=5) @@ -2089,6 +2094,8 @@ def load_general_cfg(self): # Set variables for all windows. self.startup_edit.set(idleConf.GetOption( 'main', 'General', 'editor-on-startup', type='bool')) + self.win_max.set(idleConf.GetOption( + 'main', 'EditorWindow', 'max', type='bool')) self.win_width.set(idleConf.GetOption( 'main', 'EditorWindow', 'width', type='int')) self.win_height.set(idleConf.GetOption( @@ -2125,6 +2132,14 @@ def load_general_cfg(self): self.helplist.insert(END, help_item[0]) self.set_add_delete_state() + def toggle_entry_mode(self): + if self.win_max.get(): + state = "disabled" + else: + state = "normal" + self.win_width_int.config(state=state) + self.win_height_int.config(state=state) + def help_source_selected(self, event): "Handle event for selecting additional help." self.set_add_delete_state() diff --git a/Lib/idlelib/editor.py b/Lib/idlelib/editor.py index b0f88b5463d1b6e..003898f0f3cdfca 100644 --- a/Lib/idlelib/editor.py +++ b/Lib/idlelib/editor.py @@ -107,6 +107,8 @@ def __init__(self, flist=None, filename=None, key=None, root=None): self.root = root self.menubar = Menu(root) self.top = top = window.ListedToplevel(root, menu=self.menubar) + self.top.attributes('-zoomed', idleConf.GetOption( + 'main', 'EditorWindow', 'max', type='bool')) if flist: self.tkinter_vars = flist.vars #self.top.instance_dict makes flist.inversedict available to From 1070711ff5ae5de97a7dfe74130578fae594f17b Mon Sep 17 00:00:00 2001 From: E-Paine <63801254+E-Paine@users.noreply.github.com> Date: Thu, 30 Apr 2020 16:33:37 +0100 Subject: [PATCH 2/6] Fixed Windows support Windows requires a different mechanism to Linux (the platform I originally developed on). I do not have a MacOS machine so am unable to test on MacOS. --- Lib/idlelib/editor.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Lib/idlelib/editor.py b/Lib/idlelib/editor.py index 003898f0f3cdfca..7d98ef70a1a5dd2 100644 --- a/Lib/idlelib/editor.py +++ b/Lib/idlelib/editor.py @@ -107,8 +107,11 @@ def __init__(self, flist=None, filename=None, key=None, root=None): self.root = root self.menubar = Menu(root) self.top = top = window.ListedToplevel(root, menu=self.menubar) - self.top.attributes('-zoomed', idleConf.GetOption( - 'main', 'EditorWindow', 'max', type='bool')) + if idleConf.GetOption('main', 'EditorWindow', 'max', type='bool'): + if sys.platform[:3] == 'win': + self.top.state('zoomed') + else: + self.top.attributes('-zoomed', True) if flist: self.tkinter_vars = flist.vars #self.top.instance_dict makes flist.inversedict available to From 1065abee9e9ef53c139cd6f772c280a41cc58f6a Mon Sep 17 00:00:00 2001 From: E-Paine <63801254+E-Paine@users.noreply.github.com> Date: Thu, 30 Apr 2020 21:05:35 +0100 Subject: [PATCH 3/6] Updated docstring The "create_page_general" docstring has been updated for the new checkbutton --- Lib/idlelib/configdialog.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib/idlelib/configdialog.py b/Lib/idlelib/configdialog.py index 50d96b446582021..d7ecb5a80e5c665 100644 --- a/Lib/idlelib/configdialog.py +++ b/Lib/idlelib/configdialog.py @@ -1817,6 +1817,7 @@ def create_page_general(self): (*)startup_shell_on: Radiobutton - startup_edit frame_win_size: Frame win_size_title: Label + (*)win_max_title: Checkbutton - win_max win_width_title: Label (*)win_width_int: Entry - win_width win_height_title: Label From ab58ee1d2793b1e048584957e6630a50a5454d10 Mon Sep 17 00:00:00 2001 From: E-Paine <63801254+E-Paine@users.noreply.github.com> Date: Fri, 1 May 2020 09:39:53 +0100 Subject: [PATCH 4/6] Updated IDLE news I have updated the IDLE news to contain brief details of the changes made --- Lib/idlelib/NEWS.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt index 46b15234a19c63c..a2e1b49cca7d663 100644 --- a/Lib/idlelib/NEWS.txt +++ b/Lib/idlelib/NEWS.txt @@ -56,6 +56,8 @@ bpo-26353: Stop adding newline when saving an IDLE shell window. bpo-38598: Do not try to compile IDLE shell or output windows. +bpo-23937: Add option to maximise IDLE windows on load (applies for for both shell and editor windows). + What's New in IDLE 3.8.0 (since 3.7.0) Released on 2019-10-14 From f171dd638862d6f66ecfc2bb5dff42cdf5c90986 Mon Sep 17 00:00:00 2001 From: E-Paine <63801254+E-Paine@users.noreply.github.com> Date: Fri, 1 May 2020 10:08:11 +0100 Subject: [PATCH 5/6] Wrapped news text I have wrapped the description so that it is not too long --- Lib/idlelib/NEWS.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt index a2e1b49cca7d663..83c6cf016e9cf10 100644 --- a/Lib/idlelib/NEWS.txt +++ b/Lib/idlelib/NEWS.txt @@ -56,7 +56,8 @@ bpo-26353: Stop adding newline when saving an IDLE shell window. bpo-38598: Do not try to compile IDLE shell or output windows. -bpo-23937: Add option to maximise IDLE windows on load (applies for for both shell and editor windows). +bpo-23937: Add option to maximise IDLE windows on load +(applies for for both shell and editor windows). What's New in IDLE 3.8.0 (since 3.7.0) From 773429e9ca8245f66cf20be98909fe5cc56773f7 Mon Sep 17 00:00:00 2001 From: E-Paine <63801254+E-Paine@users.noreply.github.com> Date: Fri, 1 May 2020 10:09:53 +0100 Subject: [PATCH 6/6] Removed repeated word in news I had repeated the word "for", and so the repeat has been removed --- Lib/idlelib/NEWS.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt index 83c6cf016e9cf10..4c28957a9d8b154 100644 --- a/Lib/idlelib/NEWS.txt +++ b/Lib/idlelib/NEWS.txt @@ -57,7 +57,7 @@ bpo-26353: Stop adding newline when saving an IDLE shell window. bpo-38598: Do not try to compile IDLE shell or output windows. bpo-23937: Add option to maximise IDLE windows on load -(applies for for both shell and editor windows). +(applies for both shell and editor windows). What's New in IDLE 3.8.0 (since 3.7.0)