@@ -154,9 +154,9 @@ def create_page_font_tab(self):
154154 """Return frame of widgets for Font/Tabs tab.
155155
156156 Tk Variables:
157+ font_name: Font face.
157158 font_size: Font size.
158159 font_bold: Select font bold or not.
159- font_name: Font face.
160160 Note: these 3 share var_changed_font callback.
161161 space_num: Indentation width.
162162
@@ -167,8 +167,7 @@ def create_page_font_tab(self):
167167 load_font_cfg: Set vars and fontlist.
168168 on_fontlist_select: Bound to fontlist button release
169169 or key release.
170- set_font_sample: Command for opt_menu_font_size and
171- check_font_bold.
170+ set_samples: Notify both samples of any font change.
172171 load_tab_cfg: Get current.
173172
174173 Widget Structure: (*) widgets bound to self
@@ -181,7 +180,7 @@ def create_page_font_tab(self):
181180 frame_font_param: Frame
182181 font_size_title: Label
183182 (*)opt_menu_font_size: DynOptionMenu - font_size
184- check_font_bold : Checkbutton - font_bold
183+ bold_toggle : Checkbutton - font_bold
185184 frame_font_sample: Frame
186185 (*)font_sample: Label
187186 frame_indent: LabelFrame
@@ -190,9 +189,9 @@ def create_page_font_tab(self):
190189 (*)scale_indent_size: Scale - space_num
191190 """
192191 parent = self .parent
192+ self .font_name = StringVar (parent )
193193 self .font_size = StringVar (parent )
194194 self .font_bold = BooleanVar (parent )
195- self .font_name = StringVar (parent )
196195 self .space_num = IntVar (parent )
197196 self .edit_font = tkFont .Font (parent , ('courier' , 10 , 'normal' ))
198197
@@ -218,10 +217,10 @@ def create_page_font_tab(self):
218217 self .fontlist .config (yscrollcommand = scroll_font .set )
219218 font_size_title = Label (frame_font_param , text = 'Size :' )
220219 self .opt_menu_font_size = DynOptionMenu (
221- frame_font_param , self .font_size , None , command = self .set_font_sample )
222- check_font_bold = Checkbutton (
220+ frame_font_param , self .font_size , None , command = self .set_samples )
221+ bold_toggle = Checkbutton (
223222 frame_font_param , variable = self .font_bold , onvalue = 1 ,
224- offvalue = 0 , text = 'Bold' , command = self .set_font_sample )
223+ offvalue = 0 , text = 'Bold' , command = self .set_samples )
225224 frame_font_sample = Frame (frame_font , relief = SOLID , borderwidth = 1 )
226225 self .font_sample = Label (
227226 frame_font_sample , justify = LEFT , font = self .edit_font ,
@@ -247,7 +246,7 @@ def create_page_font_tab(self):
247246 scroll_font .pack (side = LEFT , fill = Y )
248247 font_size_title .pack (side = LEFT , anchor = W )
249248 self .opt_menu_font_size .pack (side = LEFT , anchor = W )
250- check_font_bold .pack (side = LEFT , anchor = W , padx = 20 )
249+ bold_toggle .pack (side = LEFT , anchor = W , padx = 20 )
251250 frame_font_sample .pack (side = TOP , padx = 5 , pady = 5 , expand = TRUE , fill = BOTH )
252251 self .font_sample .pack (expand = TRUE , fill = BOTH )
253252 # frame_indent
@@ -292,7 +291,7 @@ def create_page_highlight(self):
292291 Widget Structure: (*) widgets bound to self
293292 frame
294293 frame_custom: LabelFrame
295- (*)text_highlight_sample : Text
294+ (*)highlight_sample : Text
296295 (*)frame_color_set: Frame
297296 button_set_color: Button
298297 (*)opt_menu_highlight_target: DynOptionMenu - highlight_target
@@ -342,11 +341,11 @@ def create_page_highlight(self):
342341 frame_theme = LabelFrame (frame , borderwidth = 2 , relief = GROOVE ,
343342 text = ' Highlighting Theme ' )
344343 #frame_custom
345- self .text_highlight_sample = Text (
344+ self .highlight_sample = Text (
346345 frame_custom , relief = SOLID , borderwidth = 1 ,
347346 font = ('courier' , 12 , '' ), cursor = 'hand2' , width = 21 , height = 11 ,
348347 takefocus = FALSE , highlightthickness = 0 , wrap = NONE )
349- text = self .text_highlight_sample
348+ text = self .highlight_sample
350349 text .bind ('<Double-Button-1>' , lambda e : 'break' )
351350 text .bind ('<B1-Motion>' , lambda e : 'break' )
352351 text_and_tags = (
@@ -416,7 +415,7 @@ def tem(event, elem=element):
416415 #frame_custom
417416 self .frame_color_set .pack (side = TOP , padx = 5 , pady = 5 , expand = TRUE , fill = X )
418417 frame_fg_bg_toggle .pack (side = TOP , padx = 5 , pady = 0 )
419- self .text_highlight_sample .pack (
418+ self .highlight_sample .pack (
420419 side = TOP , padx = 5 , pady = 5 , expand = TRUE , fill = BOTH )
421420 button_set_color .pack (side = TOP , expand = TRUE , fill = X , padx = 8 , pady = 4 )
422421 self .opt_menu_highlight_target .pack (
@@ -1142,7 +1141,7 @@ def on_new_color_set(self):
11421141 self .frame_color_set .config (bg = new_color ) # Set sample.
11431142 plane = 'foreground' if self .fg_bg_toggle .get () else 'background'
11441143 sample_element = self .theme_elements [self .highlight_target .get ()][0 ]
1145- self .text_highlight_sample .tag_config (sample_element , ** {plane :new_color })
1144+ self .highlight_sample .tag_config (sample_element , ** {plane :new_color })
11461145 theme = self .custom_theme .get ()
11471146 theme_element = sample_element + '-' + plane
11481147 changes .add_option ('highlight' , theme , theme_element , new_color )
@@ -1210,41 +1209,25 @@ def on_fontlist_select(self, event):
12101209 """Handle selecting a font from the list.
12111210
12121211 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
1212+ Set font_name and example displays to selection.
12201213 """
12211214 font = self .fontlist .get (
12221215 ACTIVE if event .type .name == 'KeyRelease' else ANCHOR )
12231216 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.
1217+ self .set_samples ()
12281218
1229- Attributes accessed:
1230- font_name
1231- font_bold
1232- font_size
1219+ def set_samples (self , event = None ):
1220+ """Update update both screen samples with the font settings.
12331221
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.
1237-
1238- Called from:
1239- handler for opt_menu_font_size and check_font_bold
1240- on_fontlist_select
1241- load_font_cfg
1222+ Called on font initialization and change events.
1223+ Accesses font_name, font_size, and font_bold Variables.
1224+ Updates font_sample and hightlight page highlight_sample.
12421225 """
12431226 font_name = self .font_name .get ()
12441227 font_weight = tkFont .BOLD if self .font_bold .get () else tkFont .NORMAL
12451228 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 )
1229+ self .font_sample [ ' font' ] = new_font
1230+ self .highlight_sample [ ' font' ] = new_font
12481231
12491232 def set_highlight_target (self ):
12501233 """Set fg/bg toggle and color based on highlight tag target.
@@ -1289,15 +1272,15 @@ def set_color_sample(self):
12891272 theme_elements
12901273 highlight_target
12911274 fg_bg_toggle
1292- text_highlight_sample
1275+ highlight_sample
12931276
12941277 Attributes updated:
12951278 frame_color_set
12961279 """
12971280 # Set the color sample area.
12981281 tag = self .theme_elements [self .highlight_target .get ()][0 ]
12991282 plane = 'foreground' if self .fg_bg_toggle .get () else 'background'
1300- color = self .text_highlight_sample .tag_cget (tag , plane )
1283+ color = self .highlight_sample .tag_cget (tag , plane )
13011284 self .frame_color_set .config (bg = color )
13021285
13031286 def paint_theme_sample (self ):
@@ -1310,7 +1293,7 @@ def paint_theme_sample(self):
13101293 custom_theme
13111294
13121295 Attributes updated:
1313- text_highlight_sample : Set the tag elements to the theme.
1296+ highlight_sample : Set the tag elements to the theme.
13141297
13151298 Methods:
13161299 set_color_sample
@@ -1337,7 +1320,7 @@ def paint_theme_sample(self):
13371320 colors ['foreground' ] = theme_dict [element + '-foreground' ]
13381321 if element + '-background' in theme_dict :
13391322 colors ['background' ] = theme_dict [element + '-background' ]
1340- self .text_highlight_sample .tag_config (element , ** colors )
1323+ self .highlight_sample .tag_config (element , ** colors )
13411324 self .set_color_sample ()
13421325
13431326 def help_source_selected (self , event ):
@@ -1424,7 +1407,7 @@ def load_font_cfg(self):
14241407 font_bold: Set to current font weight.
14251408
14261409 Methods:
1427- set_font_sample
1410+ set_samples
14281411 """
14291412 # Set base editor font selection list.
14301413 fonts = list (tkFont .families (self ))
@@ -1452,7 +1435,7 @@ def load_font_cfg(self):
14521435 # Set font weight.
14531436 self .font_bold .set (font_bold )
14541437 # Set font sample.
1455- self .set_font_sample ()
1438+ self .set_samples ()
14561439
14571440 def load_tab_cfg (self ):
14581441 """Load current configuration settings for the tab options.
0 commit comments