@@ -153,22 +153,29 @@ def create_action_buttons(self):
153153 def create_page_font_tab (self ):
154154 """Return frame of widgets for Font/Tabs tab.
155155
156+ Enable users to provisionally change font face, size, or
157+ boldness and to see the consequence of proposed choices. Each
158+ action set 3 options in changes structuree and changes the
159+ corresponding aspect of the font sample on this page and
160+ highlight sample on highlight page.
161+
162+ Enable users to change spaces entered for indent tabs.
163+
156164 Tk Variables:
165+ font_name: Font face.
157166 font_size: Font size.
158167 font_bold: Select font bold or not.
159- font_name: Font face.
160168 Note: these 3 share var_changed_font callback.
161169 space_num: Indentation width.
162170
163171 Data Attribute:
164- edit_font: Font widget with default font name, size, and weight.
172+ edit_font: Font with default font name, size, and weight.
165173
166174 Methods:
167175 load_font_cfg: Set vars and fontlist.
168176 on_fontlist_select: Bound to fontlist button release
169177 or key release.
170- set_font_sample: Command for opt_menu_font_size and
171- check_font_bold.
178+ set_samples: Notify both samples of any font change.
172179 load_tab_cfg: Get current.
173180
174181 Widget Structure: (*) widgets bound to self
@@ -181,7 +188,7 @@ def create_page_font_tab(self):
181188 frame_font_param: Frame
182189 font_size_title: Label
183190 (*)opt_menu_font_size: DynOptionMenu - font_size
184- check_font_bold : Checkbutton - font_bold
191+ (*)bold_toggle : Checkbutton - font_bold
185192 frame_font_sample: Frame
186193 (*)font_sample: Label
187194 frame_indent: LabelFrame
@@ -190,9 +197,9 @@ def create_page_font_tab(self):
190197 (*)scale_indent_size: Scale - space_num
191198 """
192199 parent = self .parent
200+ self .font_name = StringVar (parent )
193201 self .font_size = StringVar (parent )
194202 self .font_bold = BooleanVar (parent )
195- self .font_name = StringVar (parent )
196203 self .space_num = IntVar (parent )
197204 self .edit_font = tkFont .Font (parent , ('courier' , 10 , 'normal' ))
198205
@@ -218,10 +225,10 @@ def create_page_font_tab(self):
218225 self .fontlist .config (yscrollcommand = scroll_font .set )
219226 font_size_title = Label (frame_font_param , text = 'Size :' )
220227 self .opt_menu_font_size = DynOptionMenu (
221- frame_font_param , self .font_size , None , command = self .set_font_sample )
222- check_font_bold = Checkbutton (
228+ frame_font_param , self .font_size , None , command = self .set_samples )
229+ self . bold_toggle = Checkbutton (
223230 frame_font_param , variable = self .font_bold , onvalue = 1 ,
224- offvalue = 0 , text = 'Bold' , command = self .set_font_sample )
231+ offvalue = 0 , text = 'Bold' , command = self .set_samples )
225232 frame_font_sample = Frame (frame_font , relief = SOLID , borderwidth = 1 )
226233 self .font_sample = Label (
227234 frame_font_sample , justify = LEFT , font = self .edit_font ,
@@ -247,7 +254,7 @@ def create_page_font_tab(self):
247254 scroll_font .pack (side = LEFT , fill = Y )
248255 font_size_title .pack (side = LEFT , anchor = W )
249256 self .opt_menu_font_size .pack (side = LEFT , anchor = W )
250- check_font_bold .pack (side = LEFT , anchor = W , padx = 20 )
257+ self . bold_toggle .pack (side = LEFT , anchor = W , padx = 20 )
251258 frame_font_sample .pack (side = TOP , padx = 5 , pady = 5 , expand = TRUE , fill = BOTH )
252259 self .font_sample .pack (expand = TRUE , fill = BOTH )
253260 # frame_indent
@@ -292,7 +299,7 @@ def create_page_highlight(self):
292299 Widget Structure: (*) widgets bound to self
293300 frame
294301 frame_custom: LabelFrame
295- (*)text_highlight_sample : Text
302+ (*)highlight_sample : Text
296303 (*)frame_color_set: Frame
297304 button_set_color: Button
298305 (*)opt_menu_highlight_target: DynOptionMenu - highlight_target
@@ -342,11 +349,11 @@ def create_page_highlight(self):
342349 frame_theme = LabelFrame (frame , borderwidth = 2 , relief = GROOVE ,
343350 text = ' Highlighting Theme ' )
344351 #frame_custom
345- self .text_highlight_sample = Text (
352+ self .highlight_sample = Text (
346353 frame_custom , relief = SOLID , borderwidth = 1 ,
347354 font = ('courier' , 12 , '' ), cursor = 'hand2' , width = 21 , height = 11 ,
348355 takefocus = FALSE , highlightthickness = 0 , wrap = NONE )
349- text = self .text_highlight_sample
356+ text = self .highlight_sample
350357 text .bind ('<Double-Button-1>' , lambda e : 'break' )
351358 text .bind ('<B1-Motion>' , lambda e : 'break' )
352359 text_and_tags = (
@@ -416,7 +423,7 @@ def tem(event, elem=element):
416423 #frame_custom
417424 self .frame_color_set .pack (side = TOP , padx = 5 , pady = 5 , expand = TRUE , fill = X )
418425 frame_fg_bg_toggle .pack (side = TOP , padx = 5 , pady = 0 )
419- self .text_highlight_sample .pack (
426+ self .highlight_sample .pack (
420427 side = TOP , padx = 5 , pady = 5 , expand = TRUE , fill = BOTH )
421428 button_set_color .pack (side = TOP , expand = TRUE , fill = X , padx = 8 , pady = 4 )
422429 self .opt_menu_highlight_target .pack (
@@ -1142,7 +1149,7 @@ def on_new_color_set(self):
11421149 self .frame_color_set .config (bg = new_color ) # Set sample.
11431150 plane = 'foreground' if self .fg_bg_toggle .get () else 'background'
11441151 sample_element = self .theme_elements [self .highlight_target .get ()][0 ]
1145- self .text_highlight_sample .tag_config (sample_element , ** {plane :new_color })
1152+ self .highlight_sample .tag_config (sample_element , ** {plane :new_color })
11461153 theme = self .custom_theme .get ()
11471154 theme_element = sample_element + '-' + plane
11481155 changes .add_option ('highlight' , theme , theme_element , new_color )
@@ -1210,41 +1217,25 @@ def on_fontlist_select(self, event):
12101217 """Handle selecting a font from the list.
12111218
12121219 Event can result from either mouse click or Up or Down key.
1213- Set font_name and example display to selection.
1214-
1215- Attributes updated:
1216- font_name: Set to name selected from fontlist.
1217-
1218- Methods:
1219- set_font_sample
1220+ Set font_name and example displays to selection.
12201221 """
12211222 font = self .fontlist .get (
12221223 ACTIVE if event .type .name == 'KeyRelease' else ANCHOR )
12231224 self .font_name .set (font .lower ())
1224- self .set_font_sample ()
1225-
1226- def set_font_sample (self , event = None ):
1227- """Update the screen samples with the font settings from the dialog.
1228-
1229- Attributes accessed:
1230- font_name
1231- font_bold
1232- font_size
1225+ self .set_samples ()
12331226
1234- Attributes updated:
1235- font_sample: Set to selected font name, size, and weight.
1236- text_highlight_sample: Set to selected font name, size, and weight.
1227+ def set_samples (self , event = None ):
1228+ """Update update both screen samples with the font settings.
12371229
1238- Called from:
1239- handler for opt_menu_font_size and check_font_bold
1240- on_fontlist_select
1241- load_font_cfg
1230+ Called on font initialization and change events.
1231+ Accesses font_name, font_size, and font_bold Variables.
1232+ Updates font_sample and hightlight page highlight_sample.
12421233 """
12431234 font_name = self .font_name .get ()
12441235 font_weight = tkFont .BOLD if self .font_bold .get () else tkFont .NORMAL
12451236 new_font = (font_name , self .font_size .get (), font_weight )
1246- self .font_sample . config ( font = new_font )
1247- self .text_highlight_sample . configure ( font = new_font )
1237+ self .font_sample [ ' font' ] = new_font
1238+ self .highlight_sample [ ' font' ] = new_font
12481239
12491240 def set_highlight_target (self ):
12501241 """Set fg/bg toggle and color based on highlight tag target.
@@ -1289,15 +1280,15 @@ def set_color_sample(self):
12891280 theme_elements
12901281 highlight_target
12911282 fg_bg_toggle
1292- text_highlight_sample
1283+ highlight_sample
12931284
12941285 Attributes updated:
12951286 frame_color_set
12961287 """
12971288 # Set the color sample area.
12981289 tag = self .theme_elements [self .highlight_target .get ()][0 ]
12991290 plane = 'foreground' if self .fg_bg_toggle .get () else 'background'
1300- color = self .text_highlight_sample .tag_cget (tag , plane )
1291+ color = self .highlight_sample .tag_cget (tag , plane )
13011292 self .frame_color_set .config (bg = color )
13021293
13031294 def paint_theme_sample (self ):
@@ -1310,7 +1301,7 @@ def paint_theme_sample(self):
13101301 custom_theme
13111302
13121303 Attributes updated:
1313- text_highlight_sample : Set the tag elements to the theme.
1304+ highlight_sample : Set the tag elements to the theme.
13141305
13151306 Methods:
13161307 set_color_sample
@@ -1337,7 +1328,7 @@ def paint_theme_sample(self):
13371328 colors ['foreground' ] = theme_dict [element + '-foreground' ]
13381329 if element + '-background' in theme_dict :
13391330 colors ['background' ] = theme_dict [element + '-background' ]
1340- self .text_highlight_sample .tag_config (element , ** colors )
1331+ self .highlight_sample .tag_config (element , ** colors )
13411332 self .set_color_sample ()
13421333
13431334 def help_source_selected (self , event ):
@@ -1424,7 +1415,7 @@ def load_font_cfg(self):
14241415 font_bold: Set to current font weight.
14251416
14261417 Methods:
1427- set_font_sample
1418+ set_samples
14281419 """
14291420 # Set base editor font selection list.
14301421 fonts = list (tkFont .families (self ))
@@ -1452,7 +1443,7 @@ def load_font_cfg(self):
14521443 # Set font weight.
14531444 self .font_bold .set (font_bold )
14541445 # Set font sample.
1455- self .set_font_sample ()
1446+ self .set_samples ()
14561447
14571448 def load_tab_cfg (self ):
14581449 """Load current configuration settings for the tab options.
0 commit comments