From 3b2b386566b7d23ccce24ad7ea68511b7a89cc85 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Tue, 25 Jul 2017 01:27:25 -0400 Subject: [PATCH 01/10] bpo-31003: IDLE - Add tests for General tab. Collect general tab functions together. --- Lib/idlelib/configdialog.py | 218 ++++++++++++++++++------------------ 1 file changed, 109 insertions(+), 109 deletions(-) diff --git a/Lib/idlelib/configdialog.py b/Lib/idlelib/configdialog.py index 1832e156dc6fac..bbca0098a5d6b5 100644 --- a/Lib/idlelib/configdialog.py +++ b/Lib/idlelib/configdialog.py @@ -785,6 +785,115 @@ def create_page_general(self): self.button_helplist_remove.pack(side=TOP, anchor=W, pady=5) return frame + def load_general_cfg(self): + "Load current configuration settings for the general options." + # Set startup state. + self.startup_edit.set(idleConf.GetOption( + 'main', 'General', 'editor-on-startup', default=1, type='bool')) + # Set autosave state. + self.autosave.set(idleConf.GetOption( + 'main', 'General', 'autosave', default=0, type='bool')) + # Set initial window size. + self.win_width.set(idleConf.GetOption( + 'main', 'EditorWindow', 'width', type='int')) + self.win_height.set(idleConf.GetOption( + 'main', 'EditorWindow', 'height', type='int')) + # Set additional help sources. + self.user_helplist = idleConf.GetAllExtraHelpSourcesList() + for help_item in self.user_helplist: + self.list_help.insert(END, help_item[0]) + self.set_helplist_button_states() + + def var_changed_win_width(self, *params): + "Store change to window width." + value = self.win_width.get() + changes.add_option('main', 'EditorWindow', 'width', value) + + def var_changed_win_height(self, *params): + "Store change to window height." + value = self.win_height.get() + changes.add_option('main', 'EditorWindow', 'height', value) + + def var_changed_startup_edit(self, *params): + "Store change to toggle for starting IDLE in the editor or shell." + value = self.startup_edit.get() + changes.add_option('main', 'General', 'editor-on-startup', value) + + def var_changed_autosave(self, *params): + "Store change to autosave." + value = self.autosave.get() + changes.add_option('main', 'General', 'autosave', value) + + def help_source_selected(self, event): + "Handle event for selecting additional help." + self.set_helplist_button_states() + + def set_helplist_button_states(self): + "Toggle the state for the help list buttons based on list entries." + if self.list_help.size() < 1: # No entries in list. + self.button_helplist_edit.config(state=DISABLED) + self.button_helplist_remove.config(state=DISABLED) + else: # Some entries. + if self.list_help.curselection(): # There currently is a selection. + self.button_helplist_edit.config(state=NORMAL) + self.button_helplist_remove.config(state=NORMAL) + else: # There currently is not a selection. + self.button_helplist_edit.config(state=DISABLED) + self.button_helplist_remove.config(state=DISABLED) + + def helplist_item_add(self): + """Handle add button for the help list. + + Query for name and location of new help sources and add + them to the list. + """ + help_source = HelpSource(self, 'New Help Source', + ).result + if help_source: + self.user_helplist.append((help_source[0], help_source[1])) + self.list_help.insert(END, help_source[0]) + self.update_user_help_changed_items() + self.set_helplist_button_states() + + def helplist_item_edit(self): + """Handle edit button for the help list. + + Query with existing help source information and update + config if the values are changed. + """ + item_index = self.list_help.index(ANCHOR) + help_source = self.user_helplist[item_index] + new_help_source = HelpSource( + self, 'Edit Help Source', + menuitem=help_source[0], + filepath=help_source[1], + ).result + if new_help_source and new_help_source != help_source: + self.user_helplist[item_index] = new_help_source + self.list_help.delete(item_index) + self.list_help.insert(item_index, new_help_source[0]) + self.update_user_help_changed_items() + self.set_helplist_button_states() + + def helplist_item_remove(self): + """Handle remove button for the help list. + + Delete the help list item from config. + """ + item_index = self.list_help.index(ANCHOR) + del(self.user_helplist[item_index]) + self.list_help.delete(item_index) + self.update_user_help_changed_items() + self.set_helplist_button_states() + + def update_user_help_changed_items(self): + "Clear and rebuild the HelpFiles section in changes" + changes['main']['HelpFiles'] = {} + for num in range(1, len(self.user_helplist) + 1): + changes.add_option( + 'main', 'HelpFiles', str(num), + ';'.join(self.user_helplist[num-1][:2])) + def attach_var_callbacks(self): "Attach callbacks to variables that can be changed." self.font_size.trace_add('write', self.var_changed_font) @@ -917,26 +1026,6 @@ def var_changed_are_keys_builtin(self, *params): else: self.var_changed_custom_keys() - def var_changed_win_width(self, *params): - "Store change to window width." - value = self.win_width.get() - changes.add_option('main', 'EditorWindow', 'width', value) - - def var_changed_win_height(self, *params): - "Store change to window height." - value = self.win_height.get() - changes.add_option('main', 'EditorWindow', 'height', value) - - def var_changed_startup_edit(self, *params): - "Store change to toggle for starting IDLE in the editor or shell." - value = self.startup_edit.get() - changes.add_option('main', 'General', 'editor-on-startup', value) - - def var_changed_autosave(self, *params): - "Store change to autosave." - value = self.autosave.get() - changes.add_option('main', 'General', 'autosave', value) - def set_theme_type(self): """Set available screen options based on builtin or custom theme. @@ -1378,76 +1467,6 @@ def paint_theme_sample(self): self.highlight_sample.tag_config(element, **colors) self.set_color_sample() - def help_source_selected(self, event): - "Handle event for selecting additional help." - self.set_helplist_button_states() - - def set_helplist_button_states(self): - "Toggle the state for the help list buttons based on list entries." - if self.list_help.size() < 1: # No entries in list. - self.button_helplist_edit.config(state=DISABLED) - self.button_helplist_remove.config(state=DISABLED) - else: # Some entries. - if self.list_help.curselection(): # There currently is a selection. - self.button_helplist_edit.config(state=NORMAL) - self.button_helplist_remove.config(state=NORMAL) - else: # There currently is not a selection. - self.button_helplist_edit.config(state=DISABLED) - self.button_helplist_remove.config(state=DISABLED) - - def helplist_item_add(self): - """Handle add button for the help list. - - Query for name and location of new help sources and add - them to the list. - """ - help_source = HelpSource(self, 'New Help Source', - ).result - if help_source: - self.user_helplist.append((help_source[0], help_source[1])) - self.list_help.insert(END, help_source[0]) - self.update_user_help_changed_items() - self.set_helplist_button_states() - - def helplist_item_edit(self): - """Handle edit button for the help list. - - Query with existing help source information and update - config if the values are changed. - """ - item_index = self.list_help.index(ANCHOR) - help_source = self.user_helplist[item_index] - new_help_source = HelpSource( - self, 'Edit Help Source', - menuitem=help_source[0], - filepath=help_source[1], - ).result - if new_help_source and new_help_source != help_source: - self.user_helplist[item_index] = new_help_source - self.list_help.delete(item_index) - self.list_help.insert(item_index, new_help_source[0]) - self.update_user_help_changed_items() - self.set_helplist_button_states() - - def helplist_item_remove(self): - """Handle remove button for the help list. - - Delete the help list item from config. - """ - item_index = self.list_help.index(ANCHOR) - del(self.user_helplist[item_index]) - self.list_help.delete(item_index) - self.update_user_help_changed_items() - self.set_helplist_button_states() - - def update_user_help_changed_items(self): - "Clear and rebuild the HelpFiles section in changes" - changes['main']['HelpFiles'] = {} - for num in range(1, len(self.user_helplist) + 1): - changes.add_option( - 'main', 'HelpFiles', str(num), - ';'.join(self.user_helplist[num-1][:2])) - def load_theme_cfg(self): """Load current configuration settings for the theme options. @@ -1531,25 +1550,6 @@ def load_key_cfg(self): keyset_name = idleConf.CurrentKeys() self.load_keys_list(keyset_name) - def load_general_cfg(self): - "Load current configuration settings for the general options." - # Set startup state. - self.startup_edit.set(idleConf.GetOption( - 'main', 'General', 'editor-on-startup', default=1, type='bool')) - # Set autosave state. - self.autosave.set(idleConf.GetOption( - 'main', 'General', 'autosave', default=0, type='bool')) - # Set initial window size. - self.win_width.set(idleConf.GetOption( - 'main', 'EditorWindow', 'width', type='int')) - self.win_height.set(idleConf.GetOption( - 'main', 'EditorWindow', 'height', type='int')) - # Set additional help sources. - self.user_helplist = idleConf.GetAllExtraHelpSourcesList() - for help_item in self.user_helplist: - self.list_help.insert(END, help_item[0]) - self.set_helplist_button_states() - def load_configs(self): """Load configuration for each page. From 3e37df28e499f63bfd57efb4bc79955ac1d3b69b Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Tue, 25 Jul 2017 01:28:55 -0400 Subject: [PATCH 02/10] News blurb. --- Misc/NEWS.d/next/IDLE/2017-07-25-01-28-35.bpo-31003.bYINVH.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/IDLE/2017-07-25-01-28-35.bpo-31003.bYINVH.rst diff --git a/Misc/NEWS.d/next/IDLE/2017-07-25-01-28-35.bpo-31003.bYINVH.rst b/Misc/NEWS.d/next/IDLE/2017-07-25-01-28-35.bpo-31003.bYINVH.rst new file mode 100644 index 00000000000000..f3dab0fd9e6627 --- /dev/null +++ b/Misc/NEWS.d/next/IDLE/2017-07-25-01-28-35.bpo-31003.bYINVH.rst @@ -0,0 +1 @@ +IDLE: Add more tests for General tab. From 976d172120b5d86ed5125e897b531872c5b422d0 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Tue, 25 Jul 2017 02:06:58 -0400 Subject: [PATCH 03/10] Describe start, save, and size options. Rename widgets. Adapt tests to new names and test all radiobuttons. --- Lib/idlelib/configdialog.py | 66 +++++++++++----------- Lib/idlelib/idle_test/test_configdialog.py | 13 ++++- 2 files changed, 45 insertions(+), 34 deletions(-) diff --git a/Lib/idlelib/configdialog.py b/Lib/idlelib/configdialog.py index bbca0098a5d6b5..54728232a9512e 100644 --- a/Lib/idlelib/configdialog.py +++ b/Lib/idlelib/configdialog.py @@ -653,14 +653,16 @@ def create_page_keys(self): def create_page_general(self): """Return frame of widgets for General tab. - Tk Variables: - win_width: Initial window width in characters. - win_height: Initial window height in characters. - startup_edit: Selector for opening in editor or shell mode. - autosave: Selector for save prompt popup when using Run. + Enable user to set general options. Load_general_cfg loads + current values. Radiobuttons startup_shell_on and + startup_editor_on set var startup_edit. Radiobuttons save_ask_on + and save_auto_on set var autosave. Entry boxes win_width_int and + win_height_int set var win_width and win_height. Setting vars + invokes var_changed_var_name callback that adds option to + changes. + Methods: - load_general_config: help_source_selected: Bound to list_help button release. set_helplist_button_states: Toggle based on list. helplist_item_edit: Command for button_helplist_edit. @@ -672,18 +674,18 @@ def create_page_general(self): frame frame_run: LabelFrame startup_title: Label - (*)radio_startup_edit: Radiobutton - startup_edit - (*)radio_startup_shell: Radiobutton - startup_edit + (*)startup_editor_on: Radiobutton - startup_edit + (*)startup_shell_on: Radiobutton - startup_edit frame_save: LabelFrame run_save_title: Label - (*)radio_save_ask: Radiobutton - autosave - (*)radio_save_auto: Radiobutton - autosave + (*)save_ask_on: Radiobutton - autosave + (*)save_auto_on: Radiobutton - autosave frame_win_size: LabelFrame win_size_title: Label win_width_title: Label - (*)entry_win_width: Entry - win_width + (*)win_width_int: Entry - win_width win_height_title: Label - (*)entry_win_height: Entry - win_height + (*)win_height_int: Entry - win_height frame_help: LabelFrame frame_helplist: Frame frame_helplist_buttons: Frame @@ -694,10 +696,10 @@ def create_page_general(self): (*)list_help: ListBox """ parent = self.parent - self.win_width = StringVar(parent) - self.win_height = StringVar(parent) self.startup_edit = IntVar(parent) self.autosave = IntVar(parent) + self.win_width = StringVar(parent) + self.win_height = StringVar(parent) #widget creation #body @@ -712,18 +714,18 @@ def create_page_general(self): text=' Additional Help Sources ') #frame_run startup_title = Label(frame_run, text='At Startup') - self.radio_startup_edit = Radiobutton( + self.startup_editor_on = Radiobutton( frame_run, variable=self.startup_edit, value=1, text="Open Edit Window") - self.radio_startup_shell = Radiobutton( + self.startup_shell_on = Radiobutton( frame_run, variable=self.startup_edit, value=0, text='Open Shell Window') #frame_save run_save_title = Label(frame_save, text='At Start of Run (F5) ') - self.radio_save_ask = Radiobutton( + self.save_ask_on = Radiobutton( frame_save, variable=self.autosave, value=0, text="Prompt to Save") - self.radio_save_auto = Radiobutton( + self.save_auto_on = Radiobutton( frame_save, variable=self.autosave, value=1, text='No Prompt') #frame_win_size @@ -763,12 +765,12 @@ def create_page_general(self): frame_help.pack(side=TOP, padx=5, pady=5, expand=TRUE, fill=BOTH) #frame_run startup_title.pack(side=LEFT, anchor=W, padx=5, pady=5) - self.radio_startup_shell.pack(side=RIGHT, anchor=W, padx=5, pady=5) - self.radio_startup_edit.pack(side=RIGHT, anchor=W, padx=5, pady=5) + self.startup_shell_on.pack(side=RIGHT, anchor=W, padx=5, pady=5) + self.startup_editor_on.pack(side=RIGHT, anchor=W, padx=5, pady=5) #frame_save run_save_title.pack(side=LEFT, anchor=W, padx=5, pady=5) - self.radio_save_auto.pack(side=RIGHT, anchor=W, padx=5, pady=5) - self.radio_save_ask.pack(side=RIGHT, anchor=W, padx=5, pady=5) + self.save_auto_on.pack(side=RIGHT, anchor=W, padx=5, pady=5) + self.save_ask_on.pack(side=RIGHT, anchor=W, padx=5, pady=5) #frame_win_size win_size_title.pack(side=LEFT, anchor=W, padx=5, pady=5) self.entry_win_height.pack(side=RIGHT, anchor=E, padx=10, pady=5) @@ -804,16 +806,6 @@ def load_general_cfg(self): self.list_help.insert(END, help_item[0]) self.set_helplist_button_states() - def var_changed_win_width(self, *params): - "Store change to window width." - value = self.win_width.get() - changes.add_option('main', 'EditorWindow', 'width', value) - - def var_changed_win_height(self, *params): - "Store change to window height." - value = self.win_height.get() - changes.add_option('main', 'EditorWindow', 'height', value) - def var_changed_startup_edit(self, *params): "Store change to toggle for starting IDLE in the editor or shell." value = self.startup_edit.get() @@ -824,6 +816,16 @@ def var_changed_autosave(self, *params): value = self.autosave.get() changes.add_option('main', 'General', 'autosave', value) + def var_changed_win_width(self, *params): + "Store change to window width." + value = self.win_width.get() + changes.add_option('main', 'EditorWindow', 'width', value) + + def var_changed_win_height(self, *params): + "Store change to window height." + value = self.win_height.get() + changes.add_option('main', 'EditorWindow', 'height', value) + def help_source_selected(self, event): "Handle event for selecting additional help." self.set_helplist_button_states() diff --git a/Lib/idlelib/idle_test/test_configdialog.py b/Lib/idlelib/idle_test/test_configdialog.py index 54b2d78d667fae..4e31db7615b9ba 100644 --- a/Lib/idlelib/idle_test/test_configdialog.py +++ b/Lib/idlelib/idle_test/test_configdialog.py @@ -229,14 +229,23 @@ class GeneralTest(unittest.TestCase): def setUp(self): changes.clear() + def test_load_general(self): + pass + def test_startup(self): - dialog.radio_startup_edit.invoke() + dialog.startup_editor_on.invoke() self.assertEqual(mainpage, {'General': {'editor-on-startup': '1'}}) + changes.clear() + dialog.startup_shell_on.invoke() + self.assertEqual(mainpage, + {'General': {'editor-on-startup': '0'}}) def test_autosave(self): - dialog.radio_save_auto.invoke() + dialog.save_auto_on.invoke() self.assertEqual(mainpage, {'General': {'autosave': '1'}}) + dialog.save_ask_on.invoke() + self.assertEqual(mainpage, {'General': {'autosave': '0'}}) def test_editor_size(self): dialog.entry_win_height.insert(0, '1') From 9736a53b01b46c82b4fbbed51022a65b0173a8d3 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Tue, 25 Jul 2017 03:21:25 -0400 Subject: [PATCH 04/10] Explain help list; rename some widgets and functions. --- Lib/idlelib/configdialog.py | 115 ++++++++++++++++++------------------ 1 file changed, 58 insertions(+), 57 deletions(-) diff --git a/Lib/idlelib/configdialog.py b/Lib/idlelib/configdialog.py index 54728232a9512e..63825965395519 100644 --- a/Lib/idlelib/configdialog.py +++ b/Lib/idlelib/configdialog.py @@ -650,25 +650,25 @@ def create_page_keys(self): frames[1].pack(side=TOP, fill=X, expand=True, pady=2) return frame + def create_page_general(self): """Return frame of widgets for General tab. - Enable user to set general options. Load_general_cfg loads - current values. Radiobuttons startup_shell_on and - startup_editor_on set var startup_edit. Radiobuttons save_ask_on - and save_auto_on set var autosave. Entry boxes win_width_int and - win_height_int set var win_width and win_height. Setting vars - invokes var_changed_var_name callback that adds option to - changes. - - - Methods: - help_source_selected: Bound to list_help button release. - set_helplist_button_states: Toggle based on list. - helplist_item_edit: Command for button_helplist_edit. - helplist_item_add: Command for button_helplist_add. - helplist_item_remove: Command for button_helplist_remove. - update_user_help_changed_items: Fill in changes. + Enable users to provisionally change general options. + Load_general_cfg loads current values. Radiobuttons + startup_shell_on and startup_editor_on set var startup_edit. + Radiobuttons save_ask_on and save_auto_on set var autosave. + Entry boxes win_width_int and win_height_int set var win_width + and win_height. Setting vars invokes var_changed_var_name + callback that adds option to changes. + + Helplist: load_general_cfg loads list user_helplist with + name, position pairs and copies names to listbox helplist. + Clicking a name invokes help_source selected. Clicking + button_helplist_name invokes helplist_item_name, which also + changes user_helplist. These functions all call + set_add_delete_state. All but load call update_help_changes to + rewrite changes['main']['HelpFiles']. Widget Structure: (*) widgets bound to self frame @@ -692,8 +692,8 @@ def create_page_general(self): (*)button_helplist_edit (*)button_helplist_add (*)button_helplist_remove + (*)helplist: ListBox scroll_helplist: Scrollbar - (*)list_help: ListBox """ parent = self.parent self.startup_edit = IntVar(parent) @@ -701,10 +701,10 @@ def create_page_general(self): self.win_width = StringVar(parent) self.win_height = StringVar(parent) - #widget creation - #body + # Create widgets: + # body. frame = self.tab_pages.pages['General'].frame - #body section frames + # body section frames. frame_run = LabelFrame(frame, borderwidth=2, relief=GROOVE, text=' Startup Preferences ') frame_save = LabelFrame(frame, borderwidth=2, relief=GROOVE, @@ -712,7 +712,7 @@ def create_page_general(self): frame_win_size = Frame(frame, borderwidth=2, relief=GROOVE) frame_help = LabelFrame(frame, borderwidth=2, relief=GROOVE, text=' Additional Help Sources ') - #frame_run + # frame_run. startup_title = Label(frame_run, text='At Startup') self.startup_editor_on = Radiobutton( frame_run, variable=self.startup_edit, value=1, @@ -720,7 +720,7 @@ def create_page_general(self): self.startup_shell_on = Radiobutton( frame_run, variable=self.startup_edit, value=0, text='Open Shell Window') - #frame_save + # frame_save. run_save_title = Label(frame_save, text='At Start of Run (F5) ') self.save_ask_on = Radiobutton( frame_save, variable=self.autosave, value=0, @@ -728,7 +728,7 @@ def create_page_general(self): self.save_auto_on = Radiobutton( frame_save, variable=self.autosave, value=1, text='No Prompt') - #frame_win_size + # frame_win_size. win_size_title = Label( frame_win_size, text='Initial Window Size (in characters)') win_width_title = Label(frame_win_size, text='Width') @@ -737,16 +737,16 @@ def create_page_general(self): win_height_title = Label(frame_win_size, text='Height') self.entry_win_height = Entry( frame_win_size, textvariable=self.win_height, width=3) - #frame_help + # frame_help. frame_helplist = Frame(frame_help) frame_helplist_buttons = Frame(frame_helplist) - scroll_helplist = Scrollbar(frame_helplist) - self.list_help = Listbox( + self.helplist = Listbox( frame_helplist, height=5, takefocus=FALSE, exportselection=FALSE) - scroll_helplist.config(command=self.list_help.yview) - self.list_help.config(yscrollcommand=scroll_helplist.set) - self.list_help.bind('', self.help_source_selected) + scroll_helplist = Scrollbar(frame_helplist) + scroll_helplist.config(command=self.helplist.yview) + self.helplist.config(yscrollcommand=scroll_helplist.set) + self.helplist.bind('', self.help_source_selected) self.button_helplist_edit = Button( frame_helplist_buttons, text='Edit', state=DISABLED, width=8, command=self.helplist_item_edit) @@ -757,34 +757,35 @@ def create_page_general(self): frame_helplist_buttons, text='Remove', state=DISABLED, width=8, command=self.helplist_item_remove) - #widget packing - #body + # Pack widgets: + # body. frame_run.pack(side=TOP, padx=5, pady=5, fill=X) frame_save.pack(side=TOP, padx=5, pady=5, fill=X) frame_win_size.pack(side=TOP, padx=5, pady=5, fill=X) frame_help.pack(side=TOP, padx=5, pady=5, expand=TRUE, fill=BOTH) - #frame_run + # frame_run. startup_title.pack(side=LEFT, anchor=W, padx=5, pady=5) self.startup_shell_on.pack(side=RIGHT, anchor=W, padx=5, pady=5) self.startup_editor_on.pack(side=RIGHT, anchor=W, padx=5, pady=5) - #frame_save + # frame_save. run_save_title.pack(side=LEFT, anchor=W, padx=5, pady=5) self.save_auto_on.pack(side=RIGHT, anchor=W, padx=5, pady=5) self.save_ask_on.pack(side=RIGHT, anchor=W, padx=5, pady=5) - #frame_win_size + # frame_win_size. win_size_title.pack(side=LEFT, anchor=W, padx=5, pady=5) self.entry_win_height.pack(side=RIGHT, anchor=E, padx=10, pady=5) win_height_title.pack(side=RIGHT, anchor=E, pady=5) self.entry_win_width.pack(side=RIGHT, anchor=E, padx=10, pady=5) win_width_title.pack(side=RIGHT, anchor=E, pady=5) - #frame_help + # frame_help. frame_helplist_buttons.pack(side=RIGHT, padx=5, pady=5, fill=Y) frame_helplist.pack(side=TOP, padx=5, pady=5, expand=TRUE, fill=BOTH) scroll_helplist.pack(side=RIGHT, anchor=W, fill=Y) - self.list_help.pack(side=LEFT, anchor=E, expand=TRUE, fill=BOTH) + self.helplist.pack(side=LEFT, anchor=E, expand=TRUE, fill=BOTH) self.button_helplist_edit.pack(side=TOP, anchor=W, pady=5) self.button_helplist_add.pack(side=TOP, anchor=W) self.button_helplist_remove.pack(side=TOP, anchor=W, pady=5) + return frame def load_general_cfg(self): @@ -803,8 +804,8 @@ def load_general_cfg(self): # Set additional help sources. self.user_helplist = idleConf.GetAllExtraHelpSourcesList() for help_item in self.user_helplist: - self.list_help.insert(END, help_item[0]) - self.set_helplist_button_states() + self.helplist.insert(END, help_item[0]) + self.set_add_delete_state() def var_changed_startup_edit(self, *params): "Store change to toggle for starting IDLE in the editor or shell." @@ -828,15 +829,15 @@ def var_changed_win_height(self, *params): def help_source_selected(self, event): "Handle event for selecting additional help." - self.set_helplist_button_states() + self.set_add_delete_state() - def set_helplist_button_states(self): + def set_add_delete_state(self): "Toggle the state for the help list buttons based on list entries." - if self.list_help.size() < 1: # No entries in list. + if self.helplist.size() < 1: # No entries in list. self.button_helplist_edit.config(state=DISABLED) self.button_helplist_remove.config(state=DISABLED) else: # Some entries. - if self.list_help.curselection(): # There currently is a selection. + if self.helplist.curselection(): # There currently is a selection. self.button_helplist_edit.config(state=NORMAL) self.button_helplist_remove.config(state=NORMAL) else: # There currently is not a selection. @@ -849,13 +850,12 @@ def helplist_item_add(self): Query for name and location of new help sources and add them to the list. """ - help_source = HelpSource(self, 'New Help Source', - ).result + help_source = HelpSource(self, 'New Help Source').result if help_source: self.user_helplist.append((help_source[0], help_source[1])) - self.list_help.insert(END, help_source[0]) - self.update_user_help_changed_items() - self.set_helplist_button_states() + self.helplist.insert(END, help_source[0]) + self.update_help_changes() + self.set_add_delete_state() def helplist_item_edit(self): """Handle edit button for the help list. @@ -863,7 +863,7 @@ def helplist_item_edit(self): Query with existing help source information and update config if the values are changed. """ - item_index = self.list_help.index(ANCHOR) + item_index = self.helplist.index(ANCHOR) help_source = self.user_helplist[item_index] new_help_source = HelpSource( self, 'Edit Help Source', @@ -872,23 +872,23 @@ def helplist_item_edit(self): ).result if new_help_source and new_help_source != help_source: self.user_helplist[item_index] = new_help_source - self.list_help.delete(item_index) - self.list_help.insert(item_index, new_help_source[0]) - self.update_user_help_changed_items() - self.set_helplist_button_states() + self.helplist.delete(item_index) + self.helplist.insert(item_index, new_help_source[0]) + self.update_help_changes() + self.set_add_delete_state() def helplist_item_remove(self): """Handle remove button for the help list. Delete the help list item from config. """ - item_index = self.list_help.index(ANCHOR) + item_index = self.helplist.index(ANCHOR) del(self.user_helplist[item_index]) - self.list_help.delete(item_index) - self.update_user_help_changed_items() - self.set_helplist_button_states() + self.helplist.delete(item_index) + self.update_help_changes() + self.set_add_delete_state() - def update_user_help_changed_items(self): + def update_help_changes(self): "Clear and rebuild the HelpFiles section in changes" changes['main']['HelpFiles'] = {} for num in range(1, len(self.user_helplist) + 1): @@ -896,6 +896,7 @@ def update_user_help_changed_items(self): 'main', 'HelpFiles', str(num), ';'.join(self.user_helplist[num-1][:2])) + def attach_var_callbacks(self): "Attach callbacks to variables that can be changed." self.font_size.trace_add('write', self.var_changed_font) From 107524f7d28a9f3c8b8964841197618b7cd60e26 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Wed, 26 Jul 2017 02:52:24 -0400 Subject: [PATCH 05/10] Add remain general tag tests; use widget mapping instead of config --- Lib/idlelib/configdialog.py | 68 ++++---- Lib/idlelib/idle_test/mock_idle.py | 6 +- Lib/idlelib/idle_test/test_configdialog.py | 174 ++++++++++++++++++++- 3 files changed, 209 insertions(+), 39 deletions(-) diff --git a/Lib/idlelib/configdialog.py b/Lib/idlelib/configdialog.py index 63825965395519..30e33f5691d0e0 100644 --- a/Lib/idlelib/configdialog.py +++ b/Lib/idlelib/configdialog.py @@ -470,7 +470,7 @@ def tem(event, elem=element): event.widget.winfo_toplevel().highlight_target.set(elem) text.tag_bind( self.theme_elements[element][0], '', tem) - text.config(state=DISABLED) + text['state'] = DISABLED self.frame_color_set = Frame(frame_custom, relief=SOLID, borderwidth=1) frame_fg_bg_toggle = Frame(frame_custom) button_set_color = Button( @@ -792,7 +792,7 @@ def load_general_cfg(self): "Load current configuration settings for the general options." # Set startup state. self.startup_edit.set(idleConf.GetOption( - 'main', 'General', 'editor-on-startup', default=1, type='bool')) + 'main', 'General', 'editor-on-startup', default=0, type='bool')) # Set autosave state. self.autosave.set(idleConf.GetOption( 'main', 'General', 'autosave', default=0, type='bool')) @@ -803,6 +803,7 @@ def load_general_cfg(self): 'main', 'EditorWindow', 'height', type='int')) # Set additional help sources. self.user_helplist = idleConf.GetAllExtraHelpSourcesList() + self.helplist.delete(0, 'end') for help_item in self.user_helplist: self.helplist.insert(END, help_item[0]) self.set_add_delete_state() @@ -834,15 +835,15 @@ def help_source_selected(self, event): def set_add_delete_state(self): "Toggle the state for the help list buttons based on list entries." if self.helplist.size() < 1: # No entries in list. - self.button_helplist_edit.config(state=DISABLED) - self.button_helplist_remove.config(state=DISABLED) + self.button_helplist_edit['state'] = DISABLED + self.button_helplist_remove['state'] = DISABLED else: # Some entries. if self.helplist.curselection(): # There currently is a selection. - self.button_helplist_edit.config(state=NORMAL) - self.button_helplist_remove.config(state=NORMAL) + self.button_helplist_edit['state'] = NORMAL + self.button_helplist_remove['state'] = NORMAL else: # There currently is not a selection. - self.button_helplist_edit.config(state=DISABLED) - self.button_helplist_remove.config(state=DISABLED) + self.button_helplist_edit['state'] = DISABLED + self.button_helplist_remove['state'] = DISABLED def helplist_item_add(self): """Handle add button for the help list. @@ -852,10 +853,9 @@ def helplist_item_add(self): """ help_source = HelpSource(self, 'New Help Source').result if help_source: - self.user_helplist.append((help_source[0], help_source[1])) + self.user_helplist.append(help_source) self.helplist.insert(END, help_source[0]) self.update_help_changes() - self.set_add_delete_state() def helplist_item_edit(self): """Handle edit button for the help list. @@ -875,7 +875,7 @@ def helplist_item_edit(self): self.helplist.delete(item_index) self.helplist.insert(item_index, new_help_source[0]) self.update_help_changes() - self.set_add_delete_state() + self.set_add_delete_state() # Selected will be un-selected def helplist_item_remove(self): """Handle remove button for the help list. @@ -1048,26 +1048,26 @@ def set_theme_type(self): load_theme_cfg """ if self.is_builtin_theme.get(): - self.opt_menu_theme_builtin.config(state=NORMAL) - self.opt_menu_theme_custom.config(state=DISABLED) - self.button_delete_custom_theme.config(state=DISABLED) + self.opt_menu_theme_builtin['state'] = NORMAL + self.opt_menu_theme_custom['state'] = DISABLED + self.button_delete_custom_theme['state'] = DISABLED else: - self.opt_menu_theme_builtin.config(state=DISABLED) - self.radio_theme_custom.config(state=NORMAL) - self.opt_menu_theme_custom.config(state=NORMAL) - self.button_delete_custom_theme.config(state=NORMAL) + self.opt_menu_theme_builtin['state'] = DISABLED + self.radio_theme_custom['state'] = NORMAL + self.opt_menu_theme_custom['state'] = NORMAL + self.button_delete_custom_theme['state'] = NORMAL def set_keys_type(self): "Set available screen options based on builtin or custom key set." if self.are_keys_builtin.get(): - self.opt_menu_keys_builtin.config(state=NORMAL) - self.opt_menu_keys_custom.config(state=DISABLED) - self.button_delete_custom_keys.config(state=DISABLED) + self.opt_menu_keys_builtin['state'] = NORMAL + self.opt_menu_keys_custom['state'] = DISABLED + self.button_delete_custom_keys['state'] = DISABLED else: - self.opt_menu_keys_builtin.config(state=DISABLED) - self.radio_keys_custom.config(state=NORMAL) - self.opt_menu_keys_custom.config(state=NORMAL) - self.button_delete_custom_keys.config(state=NORMAL) + self.opt_menu_keys_builtin['state'] = DISABLED + self.radio_keys_custom['state'] = NORMAL + self.opt_menu_keys_custom['state'] = NORMAL + self.button_delete_custom_keys['state'] = NORMAL def get_new_keys(self): """Handle event to change key binding for selected line. @@ -1129,7 +1129,7 @@ def save_as_new_key_set(self): def keybinding_selected(self, event): "Activate button to assign new keys to selected action." - self.button_new_keys.config(state=NORMAL) + self.button_new_keys['state'] = NORMAL def create_new_key_set(self, new_key_set_name): """Create a new custom key set with the given name. @@ -1207,7 +1207,7 @@ def delete_custom_keys(self): item_list = idleConf.GetSectionList('user', 'keys') item_list.sort() if not item_list: - self.radio_keys_custom.config(state=DISABLED) + self.radio_keys_custom['state'] = DISABLED self.opt_menu_keys_custom.SetMenu(item_list, '- no custom keys -') else: self.opt_menu_keys_custom.SetMenu(item_list, item_list[0]) @@ -1256,7 +1256,7 @@ def delete_custom_theme(self): item_list = idleConf.GetSectionList('user', 'highlight') item_list.sort() if not item_list: - self.radio_theme_custom.config(state=DISABLED) + self.radio_theme_custom['state'] = DISABLED self.opt_menu_theme_custom.SetMenu(item_list, '- no custom themes -') else: self.opt_menu_theme_custom.SetMenu(item_list, item_list[0]) @@ -1395,12 +1395,12 @@ def set_highlight_target(self): load_theme_cfg """ if self.highlight_target.get() == 'Cursor': # bg not possible - self.radio_fg.config(state=DISABLED) - self.radio_bg.config(state=DISABLED) + self.radio_fg['state'] = DISABLED + self.radio_bg['state'] = DISABLED self.fg_bg_toggle.set(1) else: # Both fg and bg can be set. - self.radio_fg.config(state=NORMAL) - self.radio_bg.config(state=NORMAL) + self.radio_fg['state'] = NORMAL + self.radio_bg['state'] = NORMAL self.fg_bg_toggle.set(1) self.set_color_sample() @@ -1503,7 +1503,7 @@ def load_theme_cfg(self): item_list = idleConf.GetSectionList('user', 'highlight') item_list.sort() if not item_list: - self.radio_theme_custom.config(state=DISABLED) + self.radio_theme_custom['state'] = DISABLED self.custom_theme.set('- no custom themes -') else: self.opt_menu_theme_custom.SetMenu(item_list, item_list[0]) @@ -1537,7 +1537,7 @@ def load_key_cfg(self): item_list = idleConf.GetSectionList('user', 'keys') item_list.sort() if not item_list: - self.radio_keys_custom.config(state=DISABLED) + self.radio_keys_custom['state'] = DISABLED self.custom_keys.set('- no custom keys -') else: self.opt_menu_keys_custom.SetMenu(item_list, item_list[0]) diff --git a/Lib/idlelib/idle_test/mock_idle.py b/Lib/idlelib/idle_test/mock_idle.py index 8f3147b1c5ce3d..f279a52fd511f0 100644 --- a/Lib/idlelib/idle_test/mock_idle.py +++ b/Lib/idlelib/idle_test/mock_idle.py @@ -13,14 +13,16 @@ class Func: self.args - capture positional arguments. self.kwds - capture keyword arguments. self.result - return or raise value set in __init__. + self.return_self - return self instead, to mock query class return. Most common use will probably be to mock instance methods. Given class instance, can set and delete as instance attribute. Mock_tk.Var and Mbox_func are special variants of this. ''' - def __init__(self, result=None): + def __init__(self, result=None, return_self=False): self.called = 0 self.result = result + self.return_self = return_self self.args = None self.kwds = None def __call__(self, *args, **kwds): @@ -29,6 +31,8 @@ def __call__(self, *args, **kwds): self.kwds = kwds if isinstance(self.result, BaseException): raise self.result + elif self.return_self: + return self else: return self.result diff --git a/Lib/idlelib/idle_test/test_configdialog.py b/Lib/idlelib/idle_test/test_configdialog.py index 4e31db7615b9ba..61d0bf96c7c2b0 100644 --- a/Lib/idlelib/idle_test/test_configdialog.py +++ b/Lib/idlelib/idle_test/test_configdialog.py @@ -3,10 +3,11 @@ Half the class creates dialog, half works with user customizations. Coverage: 46% just by creating dialog, 60% with current tests. """ +from idlelib import configdialog from idlelib.configdialog import ConfigDialog, idleConf, changes from test.support import requires requires('gui') -from tkinter import Tk +from tkinter import Tk, DISABLED, NORMAL import unittest import idlelib.config as config from idlelib.idle_test.mock_idle import Func @@ -225,12 +226,48 @@ def setUp(self): class GeneralTest(unittest.TestCase): + """Test that general tab widgets enable users to make changes. + + Test that widget actions set vars, that var changes add three + options to changes and call set_samples, and that set_samples + changes the font of both sample boxes. + """ + @classmethod + def setUpClass(cls): + # Mask instance methods used by help functions. + d = dialog + d.set = d.set_add_delete_state = Func() + d.upc = d.update_help_changes = Func() + + @classmethod + def tearDownClass(cls): + d = dialog + del d.set, d.set_add_delete_state + del d.upc, d.update_help_changes + d.helplist.delete(0, 'end') + d.user_helplist.clear() def setUp(self): changes.clear() - def test_load_general(self): - pass + def test_load_general_cfg(self): + # Set to wrong values, load, check right values. + eq = self.assertEqual + d = dialog + d.startup_edit.set(1) + d.autosave.set(1) + d.win_width.set(1) + d.win_height.set(1) + d.helplist.insert('end', 'bad') + d.user_helplist = ['bad', 'worse'] + idleConf.SetOption('main', 'HelpFiles', '1', 'name;file') + d.load_general_cfg() + eq(d.startup_edit.get(), 0) + eq(d.autosave.get(), 0) + eq(d.win_width.get(), '80') + eq(d.win_height.get(), '40') + eq(d.helplist.get(0, 'end'), ('name',)) + eq(d.user_helplist, [('name', 'file', '1')]) def test_startup(self): dialog.startup_editor_on.invoke() @@ -254,7 +291,136 @@ def test_editor_size(self): dialog.entry_win_width.insert(0, '1') self.assertEqual(mainpage, {'EditorWindow': {'width': '180'}}) - #def test_help_sources(self): pass # TODO + def test_source_selected(self): + d = dialog + d.set = d.set_add_delete_state + d.upc = d.update_help_changes + helplist = d.helplist + helplist.insert(0, 'source') + helplist.activate(0) + + helplist.focus_force() + helplist.see(0) + helplist.update() + x, y, dx, dy = helplist.bbox(0) + x += dx // 2 + y += dy // 2 + d.set.called = d.upc.called = 0 + helplist.event_generate('', x=x, y=y) + helplist.event_generate('', x=x, y=y) + self.assertEqual(helplist.get('anchor'), 'source') + self.assertTrue(d.set.called) + self.assertFalse(d.upc.called) + + def test_set_add_delete_state(self): + # Call with 0 items, 1 unselected item, 1 selected item. + eq = self.assertEqual + d = dialog + del d.set_add_delete_state # Unmask method. + sad = d.set_add_delete_state + h = d.helplist + + h.delete(0, 'end') + sad() + eq(d.button_helplist_edit['state'], DISABLED) + eq(d.button_helplist_remove['state'], DISABLED) + + h.insert(0, 'source') + sad() + eq(d.button_helplist_edit['state'], DISABLED) + eq(d.button_helplist_remove['state'], DISABLED) + + h.selection_set(0) + sad() + eq(d.button_helplist_edit['state'], NORMAL) + eq(d.button_helplist_remove['state'], NORMAL) + d.set_add_delete_state = Func() # Mask method. + + def test_helplist_item_add(self): + # Call without and twice with HelpSource result. + # Double call enables check on order. + eq = self.assertEqual + orig_helpsource = configdialog.HelpSource + hs = configdialog.HelpSource = Func(return_self=True) + d = dialog + d.helplist.delete(0, 'end') + d.user_helplist.clear() + d.set.called = d.upc.called = 0 + + hs.result = '' + d.helplist_item_add() + self.assertTrue(list(d.helplist.get(0, 'end')) == + d.user_helplist == []) + self.assertFalse(d.upc.called) + + hs.result = ('name1', 'file1') + d.helplist_item_add() + hs.result = ('name2', 'file2') + d.helplist_item_add() + eq(d.helplist.get(0, 'end'), ('name1', 'name2')) + eq(d.user_helplist, [('name1', 'file1'), ('name2', 'file2')]) + eq(d.upc.called, 2) + self.assertFalse(d.set.called) + + configdialog.HelpSource = orig_helpsource + + def test_helplist_item_edit(self): + # Call without and with HelpSource change. + eq = self.assertEqual + orig_helpsource = configdialog.HelpSource + hs = configdialog.HelpSource = Func(return_self=True) + d = dialog + d.helplist.delete(0, 'end') + d.helplist.insert(0, 'name1') + d.helplist.selection_set(0) + d.helplist.selection_anchor(0) + d.user_helplist.clear() + d.user_helplist.append(('name1', 'file1')) + d.set.called = d.upc.called = 0 + + hs.result = '' + d.helplist_item_edit() + hs.result = ('name1', 'file1') + d.helplist_item_edit() + eq(d.helplist.get(0, 'end'), ('name1',)) + eq(d.user_helplist, [('name1', 'file1')]) + self.assertFalse(d.upc.called) + + hs.result = ('name2', 'file2') + d.helplist_item_edit() + eq(d.helplist.get(0, 'end'), ('name2',)) + eq(d.user_helplist, [('name2', 'file2')]) + self.assertTrue(d.upc.called == d.set.called == 1) + + configdialog.HelpSource = orig_helpsource + + def test_helplist_item_remove(self): + eq = self.assertEqual + d = dialog + d.helplist.delete(0, 'end') + d.helplist.insert(0, 'name1') + d.helplist.selection_set(0) + d.helplist.selection_anchor(0) + d.user_helplist.clear() + d.user_helplist.append(('name1', 'file1')) + d.set.called = d.upc.called = 0 + + d.helplist_item_remove() + eq(d.helplist.get(0, 'end'), ()) + eq(d.user_helplist, []) + self.assertTrue(d.upc.called == d.set.called == 1) + + def test_update_help_changes(self): + d = dialog + del d.update_help_changes + d.user_helplist.clear() + d.user_helplist.append(('name1', 'file1')) + d.user_helplist.append(('name2', 'file2')) + + d.update_help_changes() + self.assertEqual(mainpage['HelpFiles'], + {'1': 'name1;file1', '2': 'name2;file2'}) + d.update_help_changes = Func() if __name__ == '__main__': From fd5b9e00d61d388685996bdca2159cd4de389273 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Wed, 26 Jul 2017 15:12:28 -0400 Subject: [PATCH 06/10] Change entry_win_width(height) to win_width(height)_int in code and text, matching comment. (CSabella comment). --- Lib/idlelib/configdialog.py | 8 ++++---- Lib/idlelib/idle_test/test_configdialog.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Lib/idlelib/configdialog.py b/Lib/idlelib/configdialog.py index 30e33f5691d0e0..5905067db85c0d 100644 --- a/Lib/idlelib/configdialog.py +++ b/Lib/idlelib/configdialog.py @@ -732,10 +732,10 @@ def create_page_general(self): win_size_title = Label( frame_win_size, text='Initial Window Size (in characters)') win_width_title = Label(frame_win_size, text='Width') - self.entry_win_width = Entry( + self.win_width_int = Entry( frame_win_size, textvariable=self.win_width, width=3) win_height_title = Label(frame_win_size, text='Height') - self.entry_win_height = Entry( + self.win_height_int = Entry( frame_win_size, textvariable=self.win_height, width=3) # frame_help. frame_helplist = Frame(frame_help) @@ -773,9 +773,9 @@ def create_page_general(self): self.save_ask_on.pack(side=RIGHT, anchor=W, padx=5, pady=5) # frame_win_size. win_size_title.pack(side=LEFT, anchor=W, padx=5, pady=5) - self.entry_win_height.pack(side=RIGHT, 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.entry_win_width.pack(side=RIGHT, anchor=E, padx=10, pady=5) + self.win_width_int.pack(side=RIGHT, anchor=E, padx=10, pady=5) win_width_title.pack(side=RIGHT, anchor=E, pady=5) # frame_help. frame_helplist_buttons.pack(side=RIGHT, padx=5, pady=5, fill=Y) diff --git a/Lib/idlelib/idle_test/test_configdialog.py b/Lib/idlelib/idle_test/test_configdialog.py index 61d0bf96c7c2b0..cdf06482b827db 100644 --- a/Lib/idlelib/idle_test/test_configdialog.py +++ b/Lib/idlelib/idle_test/test_configdialog.py @@ -285,10 +285,10 @@ def test_autosave(self): self.assertEqual(mainpage, {'General': {'autosave': '0'}}) def test_editor_size(self): - dialog.entry_win_height.insert(0, '1') + dialog.win_height_int.insert(0, '1') self.assertEqual(mainpage, {'EditorWindow': {'height': '140'}}) changes.clear() - dialog.entry_win_width.insert(0, '1') + dialog.win_width_int.insert(0, '1') self.assertEqual(mainpage, {'EditorWindow': {'width': '180'}}) def test_source_selected(self): From c1bc8f71c45e661b7b4120f7766937b0b5f81b51 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Wed, 26 Jul 2017 15:18:11 -0400 Subject: [PATCH 07/10] Use mapping interface (CSabella comment). --- Lib/idlelib/configdialog.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/idlelib/configdialog.py b/Lib/idlelib/configdialog.py index 5905067db85c0d..898a1ab0af5753 100644 --- a/Lib/idlelib/configdialog.py +++ b/Lib/idlelib/configdialog.py @@ -744,8 +744,8 @@ def create_page_general(self): frame_helplist, height=5, takefocus=FALSE, exportselection=FALSE) scroll_helplist = Scrollbar(frame_helplist) - scroll_helplist.config(command=self.helplist.yview) - self.helplist.config(yscrollcommand=scroll_helplist.set) + scroll_helplist['command'] = self.helplist.yview + self.helplist['yscrollcommand'] = scroll_helplist.set self.helplist.bind('', self.help_source_selected) self.button_helplist_edit = Button( frame_helplist_buttons, text='Edit', state=DISABLED, From e7b9aa08bd972bb750d2c5368431b3544d055a9c Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Wed, 26 Jul 2017 15:53:58 -0400 Subject: [PATCH 08/10] Docstring changes in response to Louie. --- Lib/idlelib/configdialog.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Lib/idlelib/configdialog.py b/Lib/idlelib/configdialog.py index 898a1ab0af5753..345816e9091ada 100644 --- a/Lib/idlelib/configdialog.py +++ b/Lib/idlelib/configdialog.py @@ -160,7 +160,7 @@ def create_page_font_tab(self): corresponding aspect of the font sample on this page and highlight sample on highlight page. - Load_font_cfg initializes font vars and widgets from + Funtion load_font_cfg initializes font vars and widgets from idleConf entries and tk. Fontlist: mouse button 1 click or up or down key invoke @@ -654,13 +654,13 @@ def create_page_keys(self): def create_page_general(self): """Return frame of widgets for General tab. - Enable users to provisionally change general options. - Load_general_cfg loads current values. Radiobuttons - startup_shell_on and startup_editor_on set var startup_edit. - Radiobuttons save_ask_on and save_auto_on set var autosave. - Entry boxes win_width_int and win_height_int set var win_width - and win_height. Setting vars invokes var_changed_var_name - callback that adds option to changes. + Enable users to provisionally change general options. Function + load_general_cfg intializes tk variables and helplist using + idleConf. Radiobuttons startup_shell_on and startup_editor_on + set var startup_edit. Radiobuttons save_ask_on and save_auto_on + set var autosave. Entry boxes win_width_int and win_height_int + set var win_width and win_height. Setting var_name invokes the + var_changed_var_name callback that adds option to changes. Helplist: load_general_cfg loads list user_helplist with name, position pairs and copies names to listbox helplist. From c43fa466ea51df514140d51f2171a72fe533326c Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Wed, 26 Jul 2017 17:10:29 -0400 Subject: [PATCH 09/10] Fix GeneralTest docstring (CSabella) --- Lib/idlelib/idle_test/test_configdialog.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Lib/idlelib/idle_test/test_configdialog.py b/Lib/idlelib/idle_test/test_configdialog.py index cdf06482b827db..f77785bcd4b176 100644 --- a/Lib/idlelib/idle_test/test_configdialog.py +++ b/Lib/idlelib/idle_test/test_configdialog.py @@ -228,9 +228,8 @@ def setUp(self): class GeneralTest(unittest.TestCase): """Test that general tab widgets enable users to make changes. - Test that widget actions set vars, that var changes add three - options to changes and call set_samples, and that set_samples - changes the font of both sample boxes. + Test that widget actions set vars, that var changes add + options to changes and that helplist works correctly. """ @classmethod def setUpClass(cls): From 073b73d33c2cda9c83555957b5991dbc1d12c0b8 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Wed, 26 Jul 2017 19:26:38 -0400 Subject: [PATCH 10/10] coverage and whitespace --- Lib/idlelib/idle_test/test_configdialog.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/idlelib/idle_test/test_configdialog.py b/Lib/idlelib/idle_test/test_configdialog.py index f77785bcd4b176..28929b146038b8 100644 --- a/Lib/idlelib/idle_test/test_configdialog.py +++ b/Lib/idlelib/idle_test/test_configdialog.py @@ -1,7 +1,7 @@ """Test idlelib.configdialog. Half the class creates dialog, half works with user customizations. -Coverage: 46% just by creating dialog, 60% with current tests. +Coverage: 63%. """ from idlelib import configdialog from idlelib.configdialog import ConfigDialog, idleConf, changes @@ -229,7 +229,7 @@ class GeneralTest(unittest.TestCase): """Test that general tab widgets enable users to make changes. Test that widget actions set vars, that var changes add - options to changes and that helplist works correctly. + options to changes and that helplist works correctly. """ @classmethod def setUpClass(cls):