From 6e1eccf266c44d30f8d24194f9d15268f8f75186 Mon Sep 17 00:00:00 2001 From: "E. Paine" <63801254+E-Paine@users.noreply.github.com> Date: Thu, 6 May 2021 16:01:38 +0100 Subject: [PATCH] IDLE support for maximising editor windows on load --- Lib/idlelib/config-main.def | 1 + Lib/idlelib/configdialog.py | 17 +++++++++++++++++ Lib/idlelib/editor.py | 5 +++++ 3 files changed, 23 insertions(+) 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 c52a04b503adb4a..77baac306ab97ea 100644 --- a/Lib/idlelib/configdialog.py +++ b/Lib/idlelib/configdialog.py @@ -1819,6 +1819,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 @@ -1866,6 +1867,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( @@ -1917,6 +1920,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, @@ -2032,6 +2037,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=NW, padx=5, pady=5) + win_max_title.pack(side=TOP, anchor=E, padx=10, pady=5) win_size_title.pack(side=LEFT, anchor=W, padx=5, 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) @@ -2091,6 +2098,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( @@ -2127,6 +2136,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 fcc8a3f08ccfe33..6909071e9603b6e 100644 --- a/Lib/idlelib/editor.py +++ b/Lib/idlelib/editor.py @@ -107,6 +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) + 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