[3.6] bpo-30981: IDLE -- Add more configdialog font page tests. (GH-… · python/cpython@04864b4 (original) (raw)
`@@ -153,22 +153,29 @@ def create_action_buttons(self):
`
153
153
`def create_page_font_tab(self):
`
154
154
`"""Return frame of widgets for Font/Tabs tab.
`
155
155
``
``
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
+
156
164
` Tk Variables:
`
``
165
`+
font_name: Font face.
`
157
166
` font_size: Font size.
`
158
167
` font_bold: Select font bold or not.
`
159
``
`-
font_name: Font face.
`
160
168
` Note: these 3 share var_changed_font callback.
`
161
169
` space_num: Indentation width.
`
162
170
``
163
171
` 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.
`
165
173
``
166
174
` Methods:
`
167
175
` load_font_cfg: Set vars and fontlist.
`
168
176
` on_fontlist_select: Bound to fontlist button release
`
169
177
` 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.
`
172
179
` load_tab_cfg: Get current.
`
173
180
``
174
181
` Widget Structure: (*) widgets bound to self
`
`@@ -181,7 +188,7 @@ def create_page_font_tab(self):
`
181
188
` frame_font_param: Frame
`
182
189
` font_size_title: Label
`
183
190
` (*)opt_menu_font_size: DynOptionMenu - font_size
`
184
``
`-
check_font_bold: Checkbutton - font_bold
`
``
191
`+
(*)bold_toggle: Checkbutton - font_bold
`
185
192
` frame_font_sample: Frame
`
186
193
` (*)font_sample: Label
`
187
194
` frame_indent: LabelFrame
`
`@@ -190,9 +197,9 @@ def create_page_font_tab(self):
`
190
197
` (*)scale_indent_size: Scale - space_num
`
191
198
` """
`
192
199
`parent = self.parent
`
``
200
`+
self.font_name = StringVar(parent)
`
193
201
`self.font_size = StringVar(parent)
`
194
202
`self.font_bold = BooleanVar(parent)
`
195
``
`-
self.font_name = StringVar(parent)
`
196
203
`self.space_num = IntVar(parent)
`
197
204
`self.edit_font = tkFont.Font(parent, ('courier', 10, 'normal'))
`
198
205
``
`@@ -218,10 +225,10 @@ def create_page_font_tab(self):
`
218
225
`self.fontlist.config(yscrollcommand=scroll_font.set)
`
219
226
`font_size_title = Label(frame_font_param, text='Size :')
`
220
227
`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(
`
223
230
`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)
`
225
232
`frame_font_sample = Frame(frame_font, relief=SOLID, borderwidth=1)
`
226
233
`self.font_sample = Label(
`
227
234
`frame_font_sample, justify=LEFT, font=self.edit_font,
`
`@@ -247,7 +254,7 @@ def create_page_font_tab(self):
`
247
254
`scroll_font.pack(side=LEFT, fill=Y)
`
248
255
`font_size_title.pack(side=LEFT, anchor=W)
`
249
256
`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)
`
251
258
`frame_font_sample.pack(side=TOP, padx=5, pady=5, expand=TRUE, fill=BOTH)
`
252
259
`self.font_sample.pack(expand=TRUE, fill=BOTH)
`
253
260
`# frame_indent
`
`@@ -292,7 +299,7 @@ def create_page_highlight(self):
`
292
299
` Widget Structure: (*) widgets bound to self
`
293
300
` frame
`
294
301
` frame_custom: LabelFrame
`
295
``
`-
(*)text_highlight_sample: Text
`
``
302
`+
(*)highlight_sample: Text
`
296
303
` (*)frame_color_set: Frame
`
297
304
` button_set_color: Button
`
298
305
` (*)opt_menu_highlight_target: DynOptionMenu - highlight_target
`
`@@ -342,11 +349,11 @@ def create_page_highlight(self):
`
342
349
`frame_theme = LabelFrame(frame, borderwidth=2, relief=GROOVE,
`
343
350
`text=' Highlighting Theme ')
`
344
351
`#frame_custom
`
345
``
`-
self.text_highlight_sample=Text(
`
``
352
`+
self.highlight_sample=Text(
`
346
353
`frame_custom, relief=SOLID, borderwidth=1,
`
347
354
`font=('courier', 12, ''), cursor='hand2', width=21, height=11,
`
348
355
`takefocus=FALSE, highlightthickness=0, wrap=NONE)
`
349
``
`-
text=self.text_highlight_sample
`
``
356
`+
text=self.highlight_sample
`
350
357
`text.bind('', lambda e: 'break')
`
351
358
`text.bind('', lambda e: 'break')
`
352
359
`text_and_tags=(
`
`@@ -416,7 +423,7 @@ def tem(event, elem=element):
`
416
423
`#frame_custom
`
417
424
`self.frame_color_set.pack(side=TOP, padx=5, pady=5, expand=TRUE, fill=X)
`
418
425
`frame_fg_bg_toggle.pack(side=TOP, padx=5, pady=0)
`
419
``
`-
self.text_highlight_sample.pack(
`
``
426
`+
self.highlight_sample.pack(
`
420
427
`side=TOP, padx=5, pady=5, expand=TRUE, fill=BOTH)
`
421
428
`button_set_color.pack(side=TOP, expand=TRUE, fill=X, padx=8, pady=4)
`
422
429
`self.opt_menu_highlight_target.pack(
`
`@@ -1142,7 +1149,7 @@ def on_new_color_set(self):
`
1142
1149
`self.frame_color_set.config(bg=new_color) # Set sample.
`
1143
1150
`plane ='foreground' if self.fg_bg_toggle.get() else 'background'
`
1144
1151
`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})
`
1146
1153
`theme = self.custom_theme.get()
`
1147
1154
`theme_element = sample_element + '-' + plane
`
1148
1155
`changes.add_option('highlight', theme, theme_element, new_color)
`
`@@ -1210,41 +1217,25 @@ def on_fontlist_select(self, event):
`
1210
1217
`"""Handle selecting a font from the list.
`
1211
1218
``
1212
1219
` 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.
`
1220
1221
` """
`
1221
1222
`font = self.fontlist.get(
`
1222
1223
`ACTIVE if event.type.name == 'KeyRelease' else ANCHOR)
`
1223
1224
`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()
`
1233
1226
``
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.
`
1237
1229
``
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.
`
1242
1233
` """
`
1243
1234
`font_name = self.font_name.get()
`
1244
1235
`font_weight = tkFont.BOLD if self.font_bold.get() else tkFont.NORMAL
`
1245
1236
`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
`
1248
1239
``
1249
1240
`def set_highlight_target(self):
`
1250
1241
`"""Set fg/bg toggle and color based on highlight tag target.
`
`@@ -1289,15 +1280,15 @@ def set_color_sample(self):
`
1289
1280
` theme_elements
`
1290
1281
` highlight_target
`
1291
1282
` fg_bg_toggle
`
1292
``
`-
text_highlight_sample
`
``
1283
`+
highlight_sample
`
1293
1284
``
1294
1285
` Attributes updated:
`
1295
1286
` frame_color_set
`
1296
1287
` """
`
1297
1288
`# Set the color sample area.
`
1298
1289
`tag = self.theme_elements[self.highlight_target.get()][0]
`
1299
1290
`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)
`
1301
1292
`self.frame_color_set.config(bg=color)
`
1302
1293
``
1303
1294
`def paint_theme_sample(self):
`
`@@ -1310,7 +1301,7 @@ def paint_theme_sample(self):
`
1310
1301
` custom_theme
`
1311
1302
``
1312
1303
` Attributes updated:
`
1313
``
`-
text_highlight_sample: Set the tag elements to the theme.
`
``
1304
`+
highlight_sample: Set the tag elements to the theme.
`
1314
1305
``
1315
1306
` Methods:
`
1316
1307
` set_color_sample
`
`@@ -1337,7 +1328,7 @@ def paint_theme_sample(self):
`
1337
1328
`colors['foreground'] = theme_dict[element + '-foreground']
`
1338
1329
`if element + '-background' in theme_dict:
`
1339
1330
`colors['background'] = theme_dict[element + '-background']
`
1340
``
`-
self.text_highlight_sample.tag_config(element, **colors)
`
``
1331
`+
self.highlight_sample.tag_config(element, **colors)
`
1341
1332
`self.set_color_sample()
`
1342
1333
``
1343
1334
`def help_source_selected(self, event):
`
`@@ -1424,7 +1415,7 @@ def load_font_cfg(self):
`
1424
1415
` font_bold: Set to current font weight.
`
1425
1416
``
1426
1417
` Methods:
`
1427
``
`-
set_font_sample
`
``
1418
`+
set_samples
`
1428
1419
` """
`
1429
1420
`# Set base editor font selection list.
`
1430
1421
`fonts = list(tkFont.families(self))
`
`@@ -1452,7 +1443,7 @@ def load_font_cfg(self):
`
1452
1443
`# Set font weight.
`
1453
1444
`self.font_bold.set(font_bold)
`
1454
1445
`# Set font sample.
`
1455
``
`-
self.set_font_sample()
`
``
1446
`+
self.set_samples()
`
1456
1447
``
1457
1448
`def load_tab_cfg(self):
`
1458
1449
`"""Load current configuration settings for the tab options.
`