Skip to content

Commit ecacbb4

Browse files
miss-islingtonterryjreedy
authored andcommitted
[3.6] bpo-13802: Use non-Latin characters in IDLE's Font settings sample. (GH-3960) (#4027)
Even if one selects a font that defines a limited subset of the unicode Basic Multilingual Plane, tcl/tk will use other fonts that define a character. The expanded example give users of non-Latin characters a better idea of what they might see in the IDLE shell and editors. To make room for the expanded sample, frames on the Font tab are re-arranged. The Font/Tabs help explains a bit about the additions. (cherry picked from commit e2e4227)
1 parent 2712247 commit ecacbb4

File tree

2 files changed

+76
-19
lines changed

2 files changed

+76
-19
lines changed

‎Lib/idlelib/configdialog.py‎

Lines changed: 61 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from tkinter import (Toplevel, Listbox, Text, Scale, Canvas,
1313
StringVar, BooleanVar, IntVar, TRUE, FALSE,
1414
TOP, BOTTOM, RIGHT, LEFT, SOLID, GROOVE, NORMAL, DISABLED,
15-
NONE, BOTH, X, Y, W, E, EW, NS, NSEW, NW,
15+
NONE, BOTH, X, Y, W, E, EW, NS, NSEW, NW, CENTER,
1616
HORIZONTAL, VERTICAL, ANCHOR, ACTIVE, END)
1717
from tkinter.ttk import (Button, Checkbutton, Entry, Frame, Label, LabelFrame,
1818
OptionMenu, Notebook, Radiobutton, Scrollbar, Style)
@@ -479,8 +479,8 @@ def create_page_font_tab(self):
479479
font_size_title: Label
480480
(*)sizelist: DynOptionMenu - font_size
481481
(*)bold_toggle: Checkbutton - font_bold
482-
frame_font_sample: Frame
483-
(*)font_sample: Label
482+
frame_sample: LabelFrame
483+
(*)font_sample: Label
484484
frame_indent: LabelFrame
485485
indent_title: Label
486486
(*)indent_scale: Scale - space_num
@@ -490,18 +490,19 @@ def create_page_font_tab(self):
490490
self.font_bold = tracers.add(BooleanVar(self), self.var_changed_font)
491491
self.space_num = tracers.add(IntVar(self), ('main', 'Indent', 'num-spaces'))
492492

493-
# Create widgets:
494-
# body and body section frames.
493+
# Define frames and widgets.
495494
frame_font = LabelFrame(
496-
self, borderwidth=2, relief=GROOVE, text=' Base Editor Font ')
495+
self, borderwidth=2, relief=GROOVE, text=' Shell/Editor Font ')
496+
frame_sample = LabelFrame(
497+
self, borderwidth=2, relief=GROOVE, text=' Font Sample ')
497498
frame_indent = LabelFrame(
498499
self, borderwidth=2, relief=GROOVE, text=' Indentation Width ')
499500
# frame_font.
500501
frame_font_name = Frame(frame_font)
501502
frame_font_param = Frame(frame_font)
502503
font_name_title = Label(
503504
frame_font_name, justify=LEFT, text='Font Face :')
504-
self.fontlist = Listbox(frame_font_name, height=5,
505+
self.fontlist = Listbox(frame_font_name, height=15,
505506
takefocus=True, exportselection=FALSE)
506507
self.fontlist.bind('<ButtonRelease-1>', self.on_fontlist_select)
507508
self.fontlist.bind('<KeyRelease-Up>', self.on_fontlist_select)
@@ -514,11 +515,37 @@ def create_page_font_tab(self):
514515
self.bold_toggle = Checkbutton(
515516
frame_font_param, variable=self.font_bold,
516517
onvalue=1, offvalue=0, text='Bold')
517-
frame_font_sample = Frame(frame_font, relief=SOLID, borderwidth=1)
518+
# frame_sample.
519+
sample = (
520+
'<ASCII/Latin1>\n'
521+
'AaBbCcDdEeFfGgHhIiJj\n1234567890#:+=(){}[]\n'
522+
'\u00a2\u00a3\u00a5\u00a7\u00a9\u00ab\u00ae\u00b6\u00bd\u011e'
523+
'\u00c0\u00c1\u00c2\u00c3\u00c4\u00c5\u00c7\u00d0\u00d8\u00df\n'
524+
'\n<IPA,Greek,Cyrillic>\n'
525+
'\u0250\u0255\u0258\u025e\u025f\u0264\u026b\u026e\u0270\u0277'
526+
'\u027b\u0281\u0283\u0286\u028e\u029e\u02a2\u02ab\u02ad\u02af\n'
527+
'\u0391\u03b1\u0392\u03b2\u0393\u03b3\u0394\u03b4\u0395\u03b5'
528+
'\u0396\u03b6\u0397\u03b7\u0398\u03b8\u0399\u03b9\u039a\u03ba\n'
529+
'\u0411\u0431\u0414\u0434\u0416\u0436\u041f\u043f\u0424\u0444'
530+
'\u0427\u0447\u042a\u044a\u042d\u044d\u0460\u0464\u046c\u04dc\n'
531+
'\n<Hebrew, Arabic>\n'
532+
'\u05d0\u05d1\u05d2\u05d3\u05d4\u05d5\u05d6\u05d7\u05d8\u05d9'
533+
'\u05da\u05db\u05dc\u05dd\u05de\u05df\u05e0\u05e1\u05e2\u05e3\n'
534+
'\u0627\u0628\u062c\u062f\u0647\u0648\u0632\u062d\u0637\u064a'
535+
'\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669\n'
536+
'\n<Devanagari, Tamil>\n'
537+
'\u0966\u0967\u0968\u0969\u096a\u096b\u096c\u096d\u096e\u096f'
538+
'\u0905\u0906\u0907\u0908\u0909\u090a\u090f\u0910\u0913\u0914\n'
539+
'\u0be6\u0be7\u0be8\u0be9\u0bea\u0beb\u0bec\u0bed\u0bee\u0bef'
540+
'\u0b85\u0b87\u0b89\u0b8e\n'
541+
'\n<East Asian>\n'
542+
'\u3007\u4e00\u4e8c\u4e09\u56db\u4e94\u516d\u4e03\u516b\u4e5d\n'
543+
'\u6c49\u5b57\u6f22\u5b57\u4eba\u6728\u706b\u571f\u91d1\u6c34\n'
544+
'\uac00\ub0d0\ub354\ub824\ubaa8\ubd64\uc218\uc720\uc988\uce58\n'
545+
'\u3042\u3044\u3046\u3048\u304a\u30a2\u30a4\u30a6\u30a8\u30aa\n'
546+
)
518547
temp_font = tkFont.Font(self, ('courier', 10, 'normal'))
519-
self.font_sample = Label(
520-
frame_font_sample, justify=LEFT, font=temp_font,
521-
text='AaBbCcDdEe\nFfGgHhIiJj\n1234567890\n#:+=(){}[]')
548+
self.font_sample = Label(frame_sample, text=sample, font=temp_font)
522549
# frame_indent.
523550
indent_title = Label(
524551
frame_indent, justify=LEFT,
@@ -527,10 +554,12 @@ def create_page_font_tab(self):
527554
frame_indent, variable=self.space_num,
528555
orient='horizontal', tickinterval=2, from_=2, to=16)
529556

530-
# Pack widgets:
531-
# body.
532-
frame_font.pack(side=LEFT, padx=5, pady=5, expand=TRUE, fill=BOTH)
533-
frame_indent.pack(side=LEFT, padx=5, pady=5, fill=Y)
557+
# Grid and pack widgets:
558+
self.columnconfigure(1, weight=1)
559+
frame_font.grid(row=0, column=0, padx=5, pady=5)
560+
frame_sample.grid(row=0, column=1, rowspan=2, padx=5, pady=5,
561+
sticky='nsew')
562+
frame_indent.grid(row=1, column=0, padx=5, pady=5, sticky='ew')
534563
# frame_font.
535564
frame_font_name.pack(side=TOP, padx=5, pady=5, fill=X)
536565
frame_font_param.pack(side=TOP, padx=5, pady=5, fill=X)
@@ -540,10 +569,9 @@ def create_page_font_tab(self):
540569
font_size_title.pack(side=LEFT, anchor=W)
541570
self.sizelist.pack(side=LEFT, anchor=W)
542571
self.bold_toggle.pack(side=LEFT, anchor=W, padx=20)
543-
frame_font_sample.pack(side=TOP, padx=5, pady=5, expand=TRUE, fill=BOTH)
572+
# frame_sample.
544573
self.font_sample.pack(expand=TRUE, fill=BOTH)
545574
# frame_indent.
546-
frame_indent.pack(side=TOP, fill=X)
547575
indent_title.pack(side=TOP, anchor=W, padx=5)
548576
self.indent_scale.pack(side=TOP, padx=5, fill=X)
549577

@@ -2108,10 +2136,24 @@ def detach(self):
21082136
dialog that are different from IDLE's default are saved in
21092137
a .idlerc directory in your home directory. Except as noted,
21102138
these changes apply to all versions of IDLE installed on this
2111-
machine. Some do not take affect until IDLE is restarted.
2112-
[Cancel] only cancels changes made since the last save.
2139+
machine. [Cancel] only cancels changes made since the last save.
21132140
'''
21142141
help_pages = {
2142+
'Fonts/Tabs':'''
2143+
Font sample: This shows what a selection of Basic Multilingual Plane
2144+
unicode characters look like for the current font selection. If the
2145+
selected font does not define a character, Tk attempts to find another
2146+
font that does. Substitute glyphs depend on what is available on a
2147+
particular system and will not necessarily have the same size as the
2148+
font selected. Line contains 20 characters up to Devanagari, 14 for
2149+
Tamil, and 10 for East Asia.
2150+
2151+
Hebrew and Arabic letters should display right to left, starting with
2152+
alef, \u05d0 and \u0627. Arabic digits display left to right. The
2153+
Devanagari and Tamil lines start with digits. The East Asian lines
2154+
are Chinese digits, Chinese Hanzi, Korean Hangul, and Japanese
2155+
Hiragana and Katakana.
2156+
''',
21152157
'Highlights': '''
21162158
Highlighting:
21172159
The IDLE Dark color theme is new in October 2015. It can only
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Use non-Latin characters in the IDLE's Font settings sample.
2+
3+
Even if one selects a font that defines a limited subset of the unicode
4+
5+
Basic Multilingual Plane, tcl/tk will use other fonts that define a
6+
7+
character. The expanded example give users of non-Latin characters
8+
9+
a better idea of what they might see in IDLE's shell and editors.
10+
11+
12+
13+
To make room for the expanded sample, frames on the Font tab are
14+
15+
re-arranged. The Font/Tabs help explains a bit about the additions.

0 commit comments

Comments
 (0)