@@ -268,27 +268,28 @@ def create_page_extensions(self):
268
268
set_extension_value: Set in userCfg['extensions'].
269
269
save_all_changed_extensions: Call extension page Save().
270
270
"""
271
- parent = self .parent
272
- frame = Frame (self .note )
273
271
self .ext_defaultCfg = idleConf .defaultCfg ['extensions' ]
274
272
self .ext_userCfg = idleConf .userCfg ['extensions' ]
275
273
self .is_int = self .register (is_int )
276
274
self .load_extensions ()
277
275
# Create widgets - a listbox shows all available extensions, with the
278
276
# controls for the extension selected in the listbox to the right.
279
277
self .extension_names = StringVar (self )
280
- frame .rowconfigure (0 , weight = 1 )
281
- frame .columnconfigure (2 , weight = 1 )
282
- self .extension_list = Listbox (frame , listvariable = self .extension_names ,
278
+ frame = Frame (self .note )
279
+ frame_ext = LabelFrame (frame , borderwidth = 2 , relief = GROOVE ,
280
+ text = ' Feature Extensions ' )
281
+ frame_ext .rowconfigure (0 , weight = 1 )
282
+ frame_ext .columnconfigure (2 , weight = 1 )
283
+ self .extension_list = Listbox (frame_ext , listvariable = self .extension_names ,
283
284
selectmode = 'browse' )
284
285
self .extension_list .bind ('<<ListboxSelect>>' , self .extension_selected )
285
- scroll = Scrollbar (frame , command = self .extension_list .yview )
286
+ scroll = Scrollbar (frame_ext , command = self .extension_list .yview )
286
287
self .extension_list .yscrollcommand = scroll .set
287
- self .details_frame = LabelFrame (frame , width = 250 , height = 250 )
288
+ self .details_frame = LabelFrame (frame_ext , width = 250 , height = 250 )
288
289
self .extension_list .grid (column = 0 , row = 0 , sticky = 'nws' )
289
290
scroll .grid (column = 1 , row = 0 , sticky = 'ns' )
290
291
self .details_frame .grid (column = 2 , row = 0 , sticky = 'nsew' , padx = [10 , 0 ])
291
- frame .configure (padding = 10 )
292
+ frame_ext .configure (padding = 10 )
292
293
self .config_frame = {}
293
294
self .current_extension = None
294
295
@@ -304,6 +305,13 @@ def create_page_extensions(self):
304
305
self .extension_list .selection_set (0 )
305
306
self .extension_selected (None )
306
307
308
+
309
+ self .frame_help = HelpFrame (frame , borderwidth = 2 , relief = GROOVE ,
310
+ text = ' Help Menu Extensions ' )
311
+ frame_ext .grid (row = 0 , column = 0 , sticky = 'nsew' )
312
+ Label (frame ).grid (row = 1 , column = 0 )
313
+ self .frame_help .grid (row = 2 , column = 0 , sticky = 'sew' )
314
+
307
315
return frame
308
316
309
317
def load_extensions (self ):
@@ -1854,14 +1862,6 @@ def create_page_general(self):
1854
1862
frame_auto_squeeze_min_lines: Frame
1855
1863
auto_squeeze_min_lines_title: Label
1856
1864
(*)auto_squeeze_min_lines_int: Entry - auto_squeeze_min_lines
1857
- frame_help: LabelFrame
1858
- frame_helplist: Frame
1859
- frame_helplist_buttons: Frame
1860
- (*)button_helplist_edit
1861
- (*)button_helplist_add
1862
- (*)button_helplist_remove
1863
- (*)helplist: ListBox
1864
- scroll_helplist: Scrollbar
1865
1865
"""
1866
1866
# Integer values need StringVar because int('') raises.
1867
1867
self .startup_edit = tracers .add (
@@ -1902,8 +1902,6 @@ def create_page_general(self):
1902
1902
text = ' Editor Preferences' )
1903
1903
frame_shell = LabelFrame (self , borderwidth = 2 , relief = GROOVE ,
1904
1904
text = ' Shell Preferences' )
1905
- frame_help = LabelFrame (self , borderwidth = 2 , relief = GROOVE ,
1906
- text = ' Additional Help Sources ' )
1907
1905
# Frame_window.
1908
1906
frame_run = Frame (frame_window , borderwidth = 0 )
1909
1907
startup_title = Label (frame_run , text = 'At Startup' )
@@ -1999,32 +1997,11 @@ def create_page_general(self):
1999
1997
validatecommand = self .digits_only , validate = 'key' ,
2000
1998
)
2001
1999
2002
- # frame_help.
2003
- frame_helplist = Frame (frame_help )
2004
- frame_helplist_buttons = Frame (frame_helplist )
2005
- self .helplist = Listbox (
2006
- frame_helplist , height = 5 , takefocus = True ,
2007
- exportselection = FALSE )
2008
- scroll_helplist = Scrollbar (frame_helplist )
2009
- scroll_helplist ['command' ] = self .helplist .yview
2010
- self .helplist ['yscrollcommand' ] = scroll_helplist .set
2011
- self .helplist .bind ('<ButtonRelease-1>' , self .help_source_selected )
2012
- self .button_helplist_edit = Button (
2013
- frame_helplist_buttons , text = 'Edit' , state = 'disabled' ,
2014
- width = 8 , command = self .helplist_item_edit )
2015
- self .button_helplist_add = Button (
2016
- frame_helplist_buttons , text = 'Add' ,
2017
- width = 8 , command = self .helplist_item_add )
2018
- self .button_helplist_remove = Button (
2019
- frame_helplist_buttons , text = 'Remove' , state = 'disabled' ,
2020
- width = 8 , command = self .helplist_item_remove )
2021
-
2022
2000
# Pack widgets:
2023
2001
# Body.
2024
2002
frame_window .pack (side = TOP , padx = 5 , pady = 5 , expand = TRUE , fill = BOTH )
2025
2003
frame_editor .pack (side = TOP , padx = 5 , pady = 5 , expand = TRUE , fill = BOTH )
2026
2004
frame_shell .pack (side = TOP , padx = 5 , pady = 5 , expand = TRUE , fill = BOTH )
2027
- frame_help .pack (side = TOP , padx = 5 , pady = 5 , expand = TRUE , fill = BOTH )
2028
2005
# frame_run.
2029
2006
frame_run .pack (side = TOP , padx = 5 , pady = 0 , fill = X )
2030
2007
startup_title .pack (side = LEFT , anchor = W , padx = 5 , pady = 5 )
@@ -2077,17 +2054,12 @@ def create_page_general(self):
2077
2054
auto_squeeze_min_lines_title .pack (side = LEFT , anchor = W , padx = 5 , pady = 5 )
2078
2055
self .auto_squeeze_min_lines_int .pack (side = TOP , padx = 5 , pady = 5 )
2079
2056
2080
- # frame_help.
2081
- frame_helplist_buttons .pack (side = RIGHT , padx = 5 , pady = 5 , fill = Y )
2082
- frame_helplist .pack (side = TOP , padx = 5 , pady = 5 , expand = TRUE , fill = BOTH )
2083
- scroll_helplist .pack (side = RIGHT , anchor = W , fill = Y )
2084
- self .helplist .pack (side = LEFT , anchor = E , expand = TRUE , fill = BOTH )
2085
- self .button_helplist_edit .pack (side = TOP , anchor = W , pady = 5 )
2086
- self .button_helplist_add .pack (side = TOP , anchor = W )
2087
- self .button_helplist_remove .pack (side = TOP , anchor = W , pady = 5 )
2088
-
2089
2057
def load_general_cfg (self ):
2090
2058
"Load current configuration settings for the general options."
2059
+ self .load_windows_cfg ()
2060
+ self .load_shelled_cfg ()
2061
+
2062
+ def load_windows_cfg (self ):
2091
2063
# Set variables for all windows.
2092
2064
self .startup_edit .set (idleConf .GetOption (
2093
2065
'main' , 'General' , 'editor-on-startup' , type = 'bool' ))
@@ -2106,6 +2078,7 @@ def load_general_cfg(self):
2106
2078
self .paren_bell .set (idleConf .GetOption (
2107
2079
'extensions' , 'ParenMatch' , 'bell' ))
2108
2080
2081
+ def load_shelled_cfg (self ):
2109
2082
# Set variables for editor windows.
2110
2083
self .autosave .set (idleConf .GetOption (
2111
2084
'main' , 'General' , 'autosave' , default = 0 , type = 'bool' ))
@@ -2120,12 +2093,63 @@ def load_general_cfg(self):
2120
2093
self .auto_squeeze_min_lines .set (idleConf .GetOption (
2121
2094
'main' , 'PyShell' , 'auto-squeeze-min-lines' , type = 'int' ))
2122
2095
2123
- # Set additional help sources.
2124
- self .user_helplist = idleConf .GetAllExtraHelpSourcesList ()
2125
- self .helplist .delete (0 , 'end' )
2126
- for help_item in self .user_helplist :
2127
- self .helplist .insert (END , help_item [0 ])
2128
- self .set_add_delete_state ()
2096
+
2097
+ class HelpFrame (LabelFrame ):
2098
+
2099
+ def __init__ (self , master , ** cfg ):
2100
+ super ().__init__ (master , ** cfg )
2101
+ self .create_frame_help ()
2102
+ self .load_helplist ()
2103
+
2104
+ def create_frame_help (self ):
2105
+ """Create LabelFrame for additional help menu sources.
2106
+
2107
+ load_helplist loads list user_helplist with
2108
+ name, position pairs and copies names to listbox helplist.
2109
+ Clicking a name invokes help_source selected. Clicking
2110
+ button_helplist_name invokes helplist_item_name, which also
2111
+ changes user_helplist. These functions all call
2112
+ set_add_delete_state. All but load call update_help_changes to
2113
+ rewrite changes['main']['HelpFiles'].
2114
+
2115
+ Widgets for HelpFrame(LabelFrame): (*) widgets bound to self
2116
+ frame_helplist: Frame
2117
+ (*)helplist: ListBox
2118
+ scroll_helplist: Scrollbar
2119
+ frame_buttons: Frame
2120
+ (*)button_helplist_edit
2121
+ (*)button_helplist_add
2122
+ (*)button_helplist_remove
2123
+ """
2124
+ # self = frame_help in dialog (until ExtPage class).
2125
+ frame_helplist = Frame (self )
2126
+ self .helplist = Listbox (
2127
+ frame_helplist , height = 5 , takefocus = True ,
2128
+ exportselection = FALSE )
2129
+ scroll_helplist = Scrollbar (frame_helplist )
2130
+ scroll_helplist ['command' ] = self .helplist .yview
2131
+ self .helplist ['yscrollcommand' ] = scroll_helplist .set
2132
+ self .helplist .bind ('<ButtonRelease-1>' , self .help_source_selected )
2133
+
2134
+ frame_buttons = Frame (self )
2135
+ self .button_helplist_edit = Button (
2136
+ frame_buttons , text = 'Edit' , state = 'disabled' ,
2137
+ width = 8 , command = self .helplist_item_edit )
2138
+ self .button_helplist_add = Button (
2139
+ frame_buttons , text = 'Add' ,
2140
+ width = 8 , command = self .helplist_item_add )
2141
+ self .button_helplist_remove = Button (
2142
+ frame_buttons , text = 'Remove' , state = 'disabled' ,
2143
+ width = 8 , command = self .helplist_item_remove )
2144
+
2145
+ # Pack frame_help.
2146
+ frame_helplist .pack (side = LEFT , padx = 5 , pady = 5 , expand = TRUE , fill = BOTH )
2147
+ self .helplist .pack (side = LEFT , anchor = E , expand = TRUE , fill = BOTH )
2148
+ scroll_helplist .pack (side = RIGHT , anchor = W , fill = Y )
2149
+ frame_buttons .pack (side = RIGHT , padx = 5 , pady = 5 , fill = Y )
2150
+ self .button_helplist_edit .pack (side = TOP , anchor = W , pady = 5 )
2151
+ self .button_helplist_add .pack (side = TOP , anchor = W )
2152
+ self .button_helplist_remove .pack (side = TOP , anchor = W , pady = 5 )
2129
2153
2130
2154
def help_source_selected (self , event ):
2131
2155
"Handle event for selecting additional help."
@@ -2195,6 +2219,14 @@ def update_help_changes(self):
2195
2219
'main' , 'HelpFiles' , str (num ),
2196
2220
';' .join (self .user_helplist [num - 1 ][:2 ]))
2197
2221
2222
+ def load_helplist (self ):
2223
+ # Set additional help sources.
2224
+ self .user_helplist = idleConf .GetAllExtraHelpSourcesList ()
2225
+ self .helplist .delete (0 , 'end' )
2226
+ for help_item in self .user_helplist :
2227
+ self .helplist .insert (END , help_item [0 ])
2228
+ self .set_add_delete_state ()
2229
+
2198
2230
2199
2231
class VarTrace :
2200
2232
"""Maintain Tk variables trace state."""
0 commit comments