[3.6] bpo-30781: IDLE - Use ttk Notebook in ConfigDialog (GH-2938) (#… · python/cpython@8364fef (original) (raw)

`@@ -15,7 +15,7 @@

`

15

15

`TOP, BOTTOM, RIGHT, LEFT, SOLID, GROOVE, NORMAL, DISABLED,

`

16

16

`NONE, BOTH, X, Y, W, E, EW, NS, NSEW, NW,

`

17

17

`HORIZONTAL, VERTICAL, ANCHOR, ACTIVE, END)

`

18

``

`-

from tkinter.ttk import Scrollbar

`

``

18

`+

from tkinter.ttk import Notebook, Scrollbar

`

19

19

`import tkinter.colorchooser as tkColorChooser

`

20

20

`import tkinter.font as tkFont

`

21

21

`import tkinter.messagebox as tkMessageBox

`

`@@ -101,15 +101,19 @@ def create_widgets(self):

`

101

101

` load_configs: Load pages except for extensions.

`

102

102

` activate_config_changes: Tell editors to reload.

`

103

103

` """

`

104

``

`-

self.tab_pages = TabbedPageSet(self,

`

105

``

`-

page_names=['Fonts/Tabs', 'Highlighting', 'Keys', 'General',

`

106

``

`-

'Extensions'])

`

107

``

`-

self.tab_pages.pack(side=TOP, expand=TRUE, fill=BOTH)

`

108

``

`-

self.create_page_font_tab()

`

109

``

`-

self.create_page_highlight()

`

110

``

`-

self.create_page_keys()

`

111

``

`-

self.create_page_general()

`

112

``

`-

self.create_page_extensions()

`

``

104

`+

self.note = note = Notebook(self, width=450, height=450)

`

``

105

`+

fontpage = self.create_page_font_tab()

`

``

106

`+

highpage = self.create_page_highlight()

`

``

107

`+

keyspage = self.create_page_keys()

`

``

108

`+

genpage = self.create_page_general()

`

``

109

`+

extpage = self.create_page_extensions()

`

``

110

`+

note.add(fontpage, text='Fonts/Tabs')

`

``

111

`+

note.add(highpage, text='Highlights')

`

``

112

`+

note.add(keyspage, text=' Keys ')

`

``

113

`+

note.add(genpage, text=' General ')

`

``

114

`+

note.add(extpage, text='Extensions')

`

``

115

`+

note.enable_traversal()

`

``

116

`+

note.pack(side=TOP, expand=TRUE, fill=BOTH)

`

113

117

`self.create_action_buttons().pack(side=BOTTOM)

`

114

118

``

115

119

`def load_configs(self):

`

`@@ -270,7 +274,7 @@ def create_page_font_tab(self):

`

270

274

``

271

275

`# Create widgets:

`

272

276

`# body and body section frames.

`

273

``

`-

frame = self.tab_pages.pages['Fonts/Tabs'].frame

`

``

277

`+

frame = Frame(self.note)

`

274

278

`frame_font = LabelFrame(

`

275

279

`frame, borderwidth=2, relief=GROOVE, text=' Base Editor Font ')

`

276

280

`frame_indent = LabelFrame(

`

`@@ -281,7 +285,7 @@ def create_page_font_tab(self):

`

281

285

`font_name_title = Label(

`

282

286

`frame_font_name, justify=LEFT, text='Font Face :')

`

283

287

`self.fontlist = Listbox(frame_font_name, height=5,

`

284

``

`-

takefocus=FALSE, exportselection=FALSE)

`

``

288

`+

takefocus=True, exportselection=FALSE)

`

285

289

`self.fontlist.bind('', self.on_fontlist_select)

`

286

290

`self.fontlist.bind('', self.on_fontlist_select)

`

287

291

`self.fontlist.bind('', self.on_fontlist_select)

`

`@@ -297,7 +301,7 @@ def create_page_font_tab(self):

`

297

301

`temp_font = tkFont.Font(parent, ('courier', 10, 'normal'))

`

298

302

`self.font_sample = Label(

`

299

303

`frame_font_sample, justify=LEFT, font=temp_font,

`

300

``

`-

text='AaBbCcDdEe\nFfGgHhIiJjK\n1234567890\n#:+=(){}[]')

`

``

304

`+

text='AaBbCcDdEe\nFfGgHhIiJj\n1234567890\n#:+=(){}[]')

`

301

305

`# frame_indent.

`

302

306

`indent_title = Label(

`

303

307

`frame_indent, justify=LEFT,

`

`@@ -493,23 +497,22 @@ def create_page_highlight(self):

`

493

497

`self.highlight_target = tracers.add(

`

494

498

`StringVar(parent), self.var_changed_highlight_target)

`

495

499

``

496

``

`-

##widget creation

`

497

``

`-

#body frame

`

498

``

`-

frame = self.tab_pages.pages['Highlighting'].frame

`

499

``

`-

#body section frames

`

``

500

`+

Widget creation:

`

``

501

`+

body frame and section frames

`

``

502

`+

frame = Frame(self.note)

`

500

503

`frame_custom = LabelFrame(frame, borderwidth=2, relief=GROOVE,

`

501

504

`text=' Custom Highlighting ')

`

502

505

`frame_theme = LabelFrame(frame, borderwidth=2, relief=GROOVE,

`

503

506

`text=' Highlighting Theme ')

`

504

507

`#frame_custom

`

505

508

`self.highlight_sample=Text(

`

506

509

`frame_custom, relief=SOLID, borderwidth=1,

`

507

``

`-

font=('courier', 12, ''), cursor='hand2', width=21, height=11,

`

``

510

`+

font=('courier', 12, ''), cursor='hand2', width=21, height=13,

`

508

511

`takefocus=FALSE, highlightthickness=0, wrap=NONE)

`

509

512

`text=self.highlight_sample

`

510

513

`text.bind('', lambda e: 'break')

`

511

514

`text.bind('', lambda e: 'break')

`

512

``

`-

text_and_tags=(

`

``

515

`+

text_and_tags=(('\n', 'normal'),

`

513

516

` ('#you can click here', 'comment'), ('\n', 'normal'),

`

514

517

` ('#to choose items', 'comment'), ('\n', 'normal'),

`

515

518

` ('def', 'keyword'), (' ', 'normal'),

`

`@@ -525,7 +528,7 @@ def create_page_highlight(self):

`

525

528

` ('cursor |', 'cursor'), ('\n ', 'normal'),

`

526

529

` ('shell', 'console'), (' ', 'normal'),

`

527

530

` ('stdout', 'stdout'), (' ', 'normal'),

`

528

``

`-

('stderr', 'stderr'), ('\n', 'normal'))

`

``

531

`+

('stderr', 'stderr'), ('\n\n', 'normal'))

`

529

532

`for texttag in text_and_tags:

`

530

533

`text.insert(END, texttag[0], texttag[1])

`

531

534

`for element in self.theme_elements:

`

`@@ -1039,10 +1042,9 @@ def create_page_keys(self):

`

1039

1042

`self.keybinding = tracers.add(

`

1040

1043

`StringVar(parent), self.var_changed_keybinding)

`

1041

1044

``

1042

``

`-

##widget creation

`

1043

``

`-

#body frame

`

1044

``

`-

frame = self.tab_pages.pages['Keys'].frame

`

1045

``

`-

#body section frames

`

``

1045

`+

Widget creation:

`

``

1046

`+

body and section frames.

`

``

1047

`+

frame = Frame(self.note)

`

1046

1048

`frame_custom = LabelFrame(

`

1047

1049

`frame, borderwidth=2, relief=GROOVE,

`

1048

1050

`text=' Custom Key Bindings ')

`

`@@ -1449,9 +1451,8 @@ def create_page_general(self):

`

1449

1451

`StringVar(parent), ('main', 'EditorWindow', 'height'))

`

1450

1452

``

1451

1453

`# Create widgets:

`

1452

``

`-

body.

`

1453

``

`-

frame = self.tab_pages.pages['General'].frame

`

1454

``

`-

body section frames.

`

``

1454

`+

body and section frames.

`

``

1455

`+

frame = Frame(self.note)

`

1455

1456

`frame_run = LabelFrame(frame, borderwidth=2, relief=GROOVE,

`

1456

1457

`text=' Startup Preferences ')

`

1457

1458

`frame_save = LabelFrame(frame, borderwidth=2, relief=GROOVE,

`

`@@ -1488,7 +1489,7 @@ def create_page_general(self):

`

1488

1489

`frame_helplist = Frame(frame_help)

`

1489

1490

`frame_helplist_buttons = Frame(frame_helplist)

`

1490

1491

`self.helplist = Listbox(

`

1491

``

`-

frame_helplist, height=5, takefocus=FALSE,

`

``

1492

`+

frame_helplist, height=5, takefocus=True,

`

1492

1493

`exportselection=FALSE)

`

1493

1494

`scroll_helplist = Scrollbar(frame_helplist)

`

1494

1495

`scroll_helplist['command'] = self.helplist.yview

`

`@@ -1669,7 +1670,7 @@ def create_page_extensions(self):

`

1669

1670

` save_all_changed_extensions: Call extension page Save().

`

1670

1671

` """

`

1671

1672

`parent = self.parent

`

1672

``

`-

frame = self.tab_pages.pages['Extensions'].frame

`

``

1673

`+

frame = Frame(self.note)

`

1673

1674

`self.ext_defaultCfg = idleConf.defaultCfg['extensions']

`

1674

1675

`self.ext_userCfg = idleConf.userCfg['extensions']

`

1675

1676

`self.is_int = self.register(is_int)

`

`@@ -1704,6 +1705,8 @@ def create_page_extensions(self):

`

1704

1705

`self.extension_list.selection_set(0)

`

1705

1706

`self.extension_selected(None)

`

1706

1707

``

``

1708

`+

return frame

`

``

1709

+

1707

1710

`def load_extensions(self):

`

1708

1711

`"Fill self.extensions with data from the default and user configs."

`

1709

1712

`self.extensions = {}

`