Skip to content

Commit 664ae29

Browse files
bpo-40468: Split IDLE settings General tab (GH-26621)
Replace it with Windows tab for Shell and Editor options and Shell/Ed for options exclusive to one of them. Create room for more options and make dialog shorter, to better fit small windows. (cherry picked from commit 275d5f7) Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
1 parent 33a7a24 commit 664ae29

File tree

3 files changed

+184
-141
lines changed

3 files changed

+184
-141
lines changed

Lib/idlelib/configdialog.py

+147-128
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,14 @@ def create_widgets(self):
116116
self.highpage = HighPage(note, self.extpage)
117117
self.fontpage = FontPage(note, self.highpage)
118118
self.keyspage = KeysPage(note, self.extpage)
119-
self.genpage = GenPage(note)
119+
self.winpage = WinPage(note)
120+
self.shedpage = ShedPage(note)
121+
120122
note.add(self.fontpage, text='Fonts/Tabs')
121123
note.add(self.highpage, text='Highlights')
122124
note.add(self.keyspage, text=' Keys ')
123-
note.add(self.genpage, text=' General ')
125+
note.add(self.winpage, text=' Windows ')
126+
note.add(self.shedpage, text=' Shell/Ed ')
124127
note.add(self.extpage, text='Extensions')
125128
note.enable_traversal()
126129
note.pack(side=TOP, expand=TRUE, fill=BOTH)
@@ -1594,14 +1597,14 @@ def delete_custom_keys(self):
15941597
self.set_keys_type()
15951598

15961599

1597-
class GenPage(Frame):
1600+
class WinPage(Frame):
15981601

15991602
def __init__(self, master):
16001603
super().__init__(master)
16011604

16021605
self.init_validators()
1603-
self.create_page_general()
1604-
self.load_general_cfg()
1606+
self.create_page_windows()
1607+
self.load_windows_cfg()
16051608

16061609
def init_validators(self):
16071610
digits_or_empty_re = re.compile(r'[0-9]*')
@@ -1610,26 +1613,17 @@ def is_digits_or_empty(s):
16101613
return digits_or_empty_re.fullmatch(s) is not None
16111614
self.digits_only = (self.register(is_digits_or_empty), '%P',)
16121615

1613-
def create_page_general(self):
1614-
"""Return frame of widgets for General tab.
1615-
1616-
Enable users to provisionally change general options. Function
1617-
load_general_cfg initializes tk variables and helplist using
1618-
idleConf. Radiobuttons startup_shell_on and startup_editor_on
1619-
set var startup_edit. Radiobuttons save_ask_on and save_auto_on
1620-
set var autosave. Entry boxes win_width_int and win_height_int
1621-
set var win_width and win_height. Setting var_name invokes the
1622-
default callback that adds option to changes.
1616+
def create_page_windows(self):
1617+
"""Return frame of widgets for Windows tab.
16231618
1624-
Helplist: load_general_cfg loads list user_helplist with
1625-
name, position pairs and copies names to listbox helplist.
1626-
Clicking a name invokes help_source selected. Clicking
1627-
button_helplist_name invokes helplist_item_name, which also
1628-
changes user_helplist. These functions all call
1629-
set_add_delete_state. All but load call update_help_changes to
1630-
rewrite changes['main']['HelpFiles'].
1619+
Enable users to provisionally change general window options.
1620+
Function load_windows_cfg initializes tk variables idleConf.
1621+
Radiobuttons startup_shell_on and startup_editor_on set var
1622+
startup_edit. Entry boxes win_width_int and win_height_int set var
1623+
win_width and win_height. Setting var_name invokes the default
1624+
callback that adds option to changes.
16311625
1632-
Widgets for GenPage(Frame): (*) widgets bound to self
1626+
Widgets for WinPage(Frame): (*) widgets bound to self
16331627
frame_window: LabelFrame
16341628
frame_run: Frame
16351629
startup_title: Label
@@ -1654,24 +1648,9 @@ def create_page_general(self):
16541648
paren_time_title: Label
16551649
(*)paren_flash_time: Entry - flash_delay
16561650
(*)bell_on: Checkbutton - paren_bell
1657-
frame_editor: LabelFrame
1658-
frame_save: Frame
1659-
run_save_title: Label
1660-
(*)save_ask_on: Radiobutton - autosave
1661-
(*)save_auto_on: Radiobutton - autosave
16621651
frame_format: Frame
16631652
format_width_title: Label
16641653
(*)format_width_int: Entry - format_width
1665-
frame_line_numbers_default: Frame
1666-
line_numbers_default_title: Label
1667-
(*)line_numbers_default_bool: Checkbutton - line_numbers_default
1668-
frame_context: Frame
1669-
context_title: Label
1670-
(*)context_int: Entry - context_lines
1671-
frame_shell: LabelFrame
1672-
frame_auto_squeeze_min_lines: Frame
1673-
auto_squeeze_min_lines_title: Label
1674-
(*)auto_squeeze_min_lines_int: Entry - auto_squeeze_min_lines
16751654
"""
16761655
# Integer values need StringVar because int('') raises.
16771656
self.startup_edit = tracers.add(
@@ -1690,29 +1669,13 @@ def create_page_general(self):
16901669
StringVar(self), ('extensions', 'ParenMatch', 'flash-delay'))
16911670
self.paren_bell = tracers.add(
16921671
BooleanVar(self), ('extensions', 'ParenMatch', 'bell'))
1693-
1694-
self.auto_squeeze_min_lines = tracers.add(
1695-
StringVar(self), ('main', 'PyShell', 'auto-squeeze-min-lines'))
1696-
1697-
self.autosave = tracers.add(
1698-
IntVar(self), ('main', 'General', 'autosave'))
16991672
self.format_width = tracers.add(
17001673
StringVar(self), ('extensions', 'FormatParagraph', 'max-width'))
1701-
self.line_numbers_default = tracers.add(
1702-
BooleanVar(self),
1703-
('main', 'EditorWindow', 'line-numbers-default'))
1704-
self.context_lines = tracers.add(
1705-
StringVar(self), ('extensions', 'CodeContext', 'maxlines'))
17061674

17071675
# Create widgets:
1708-
# Section frames.
17091676
frame_window = LabelFrame(self, borderwidth=2, relief=GROOVE,
17101677
text=' Window Preferences')
1711-
frame_editor = LabelFrame(self, borderwidth=2, relief=GROOVE,
1712-
text=' Editor Preferences')
1713-
frame_shell = LabelFrame(self, borderwidth=2, relief=GROOVE,
1714-
text=' Shell Preferences')
1715-
# Frame_window.
1678+
17161679
frame_run = Frame(frame_window, borderwidth=0)
17171680
startup_title = Label(frame_run, text='At Startup')
17181681
self.startup_editor_on = Radiobutton(
@@ -1747,8 +1710,7 @@ def create_page_general(self):
17471710
self.auto_wait_int = Entry(frame_autocomplete, width=6,
17481711
textvariable=self.autocomplete_wait,
17491712
validatecommand=self.digits_only,
1750-
validate='key',
1751-
)
1713+
validate='key')
17521714

17531715
frame_paren1 = Frame(frame_window, borderwidth=0)
17541716
paren_style_title = Label(frame_paren1, text='Paren Match Style')
@@ -1763,55 +1725,16 @@ def create_page_general(self):
17631725
frame_paren2, textvariable=self.flash_delay, width=6)
17641726
self.bell_on = Checkbutton(
17651727
frame_paren2, text="Bell on Mismatch", variable=self.paren_bell)
1766-
1767-
# Frame_editor.
1768-
frame_save = Frame(frame_editor, borderwidth=0)
1769-
run_save_title = Label(frame_save, text='At Start of Run (F5) ')
1770-
self.save_ask_on = Radiobutton(
1771-
frame_save, variable=self.autosave, value=0,
1772-
text="Prompt to Save")
1773-
self.save_auto_on = Radiobutton(
1774-
frame_save, variable=self.autosave, value=1,
1775-
text='No Prompt')
1776-
1777-
frame_format = Frame(frame_editor, borderwidth=0)
1728+
frame_format = Frame(frame_window, borderwidth=0)
17781729
format_width_title = Label(frame_format,
17791730
text='Format Paragraph Max Width')
17801731
self.format_width_int = Entry(
17811732
frame_format, textvariable=self.format_width, width=4,
17821733
validatecommand=self.digits_only, validate='key',
1783-
)
1784-
1785-
frame_line_numbers_default = Frame(frame_editor, borderwidth=0)
1786-
line_numbers_default_title = Label(
1787-
frame_line_numbers_default, text='Show line numbers in new windows')
1788-
self.line_numbers_default_bool = Checkbutton(
1789-
frame_line_numbers_default,
1790-
variable=self.line_numbers_default,
1791-
width=1)
1792-
1793-
frame_context = Frame(frame_editor, borderwidth=0)
1794-
context_title = Label(frame_context, text='Max Context Lines :')
1795-
self.context_int = Entry(
1796-
frame_context, textvariable=self.context_lines, width=3,
1797-
validatecommand=self.digits_only, validate='key',
1798-
)
1799-
1800-
# Frame_shell.
1801-
frame_auto_squeeze_min_lines = Frame(frame_shell, borderwidth=0)
1802-
auto_squeeze_min_lines_title = Label(frame_auto_squeeze_min_lines,
1803-
text='Auto-Squeeze Min. Lines:')
1804-
self.auto_squeeze_min_lines_int = Entry(
1805-
frame_auto_squeeze_min_lines, width=4,
1806-
textvariable=self.auto_squeeze_min_lines,
1807-
validatecommand=self.digits_only, validate='key',
1808-
)
1734+
)
18091735

18101736
# Pack widgets:
1811-
# Body.
18121737
frame_window.pack(side=TOP, padx=5, pady=5, expand=TRUE, fill=BOTH)
1813-
frame_editor.pack(side=TOP, padx=5, pady=5, expand=TRUE, fill=BOTH)
1814-
frame_shell.pack(side=TOP, padx=5, pady=5, expand=TRUE, fill=BOTH)
18151738
# frame_run.
18161739
frame_run.pack(side=TOP, padx=5, pady=0, fill=X)
18171740
startup_title.pack(side=LEFT, anchor=W, padx=5, pady=5)
@@ -1840,34 +1763,10 @@ def create_page_general(self):
18401763
paren_time_title.pack(side=LEFT, anchor=W, padx=5)
18411764
self.bell_on.pack(side=RIGHT, anchor=E, padx=15, pady=5)
18421765
self.paren_flash_time.pack(side=TOP, anchor=W, padx=15, pady=5)
1843-
1844-
# frame_save.
1845-
frame_save.pack(side=TOP, padx=5, pady=0, fill=X)
1846-
run_save_title.pack(side=LEFT, anchor=W, padx=5, pady=5)
1847-
self.save_auto_on.pack(side=RIGHT, anchor=W, padx=5, pady=5)
1848-
self.save_ask_on.pack(side=RIGHT, anchor=W, padx=5, pady=5)
18491766
# frame_format.
18501767
frame_format.pack(side=TOP, padx=5, pady=0, fill=X)
18511768
format_width_title.pack(side=LEFT, anchor=W, padx=5, pady=5)
18521769
self.format_width_int.pack(side=TOP, padx=10, pady=5)
1853-
# frame_line_numbers_default.
1854-
frame_line_numbers_default.pack(side=TOP, padx=5, pady=0, fill=X)
1855-
line_numbers_default_title.pack(side=LEFT, anchor=W, padx=5, pady=5)
1856-
self.line_numbers_default_bool.pack(side=LEFT, padx=5, pady=5)
1857-
# frame_context.
1858-
frame_context.pack(side=TOP, padx=5, pady=0, fill=X)
1859-
context_title.pack(side=LEFT, anchor=W, padx=5, pady=5)
1860-
self.context_int.pack(side=TOP, padx=5, pady=5)
1861-
1862-
# frame_auto_squeeze_min_lines
1863-
frame_auto_squeeze_min_lines.pack(side=TOP, padx=5, pady=0, fill=X)
1864-
auto_squeeze_min_lines_title.pack(side=LEFT, anchor=W, padx=5, pady=5)
1865-
self.auto_squeeze_min_lines_int.pack(side=TOP, padx=5, pady=5)
1866-
1867-
def load_general_cfg(self):
1868-
"Load current configuration settings for the general options."
1869-
self.load_windows_cfg()
1870-
self.load_shelled_cfg()
18711770

18721771
def load_windows_cfg(self):
18731772
# Set variables for all windows.
@@ -1887,22 +1786,142 @@ def load_windows_cfg(self):
18871786
'extensions', 'ParenMatch', 'flash-delay', type='int'))
18881787
self.paren_bell.set(idleConf.GetOption(
18891788
'extensions', 'ParenMatch', 'bell'))
1789+
self.format_width.set(idleConf.GetOption(
1790+
'extensions', 'FormatParagraph', 'max-width', type='int'))
1791+
1792+
1793+
class ShedPage(Frame):
1794+
1795+
def __init__(self, master):
1796+
super().__init__(master)
1797+
1798+
self.init_validators()
1799+
self.create_page_shed()
1800+
self.load_shelled_cfg()
1801+
1802+
def init_validators(self):
1803+
digits_or_empty_re = re.compile(r'[0-9]*')
1804+
def is_digits_or_empty(s):
1805+
"Return 's is blank or contains only digits'"
1806+
return digits_or_empty_re.fullmatch(s) is not None
1807+
self.digits_only = (self.register(is_digits_or_empty), '%P',)
1808+
1809+
def create_page_shed(self):
1810+
"""Return frame of widgets for Shell/Ed tab.
1811+
1812+
Enable users to provisionally change shell and editor options.
1813+
Function load_shed_cfg initializes tk variables using idleConf.
1814+
Entry box auto_squeeze_min_lines_int sets
1815+
auto_squeeze_min_lines_int. Setting var_name invokes the
1816+
default callback that adds option to changes.
1817+
1818+
Widgets for ShedPage(Frame): (*) widgets bound to self
1819+
frame_shell: LabelFrame
1820+
frame_auto_squeeze_min_lines: Frame
1821+
auto_squeeze_min_lines_title: Label
1822+
(*)auto_squeeze_min_lines_int: Entry -
1823+
auto_squeeze_min_lines
1824+
frame_editor: LabelFrame
1825+
frame_save: Frame
1826+
run_save_title: Label
1827+
(*)save_ask_on: Radiobutton - autosave
1828+
(*)save_auto_on: Radiobutton - autosave
1829+
frame_format: Frame
1830+
format_width_title: Label
1831+
(*)format_width_int: Entry - format_width
1832+
frame_line_numbers_default: Frame
1833+
line_numbers_default_title: Label
1834+
(*)line_numbers_default_bool: Checkbutton - line_numbers_default
1835+
frame_context: Frame
1836+
context_title: Label
1837+
(*)context_int: Entry - context_lines
1838+
"""
1839+
# Integer values need StringVar because int('') raises.
1840+
self.auto_squeeze_min_lines = tracers.add(
1841+
StringVar(self), ('main', 'PyShell', 'auto-squeeze-min-lines'))
1842+
1843+
self.autosave = tracers.add(
1844+
IntVar(self), ('main', 'General', 'autosave'))
1845+
self.line_numbers_default = tracers.add(
1846+
BooleanVar(self),
1847+
('main', 'EditorWindow', 'line-numbers-default'))
1848+
self.context_lines = tracers.add(
1849+
StringVar(self), ('extensions', 'CodeContext', 'maxlines'))
1850+
1851+
# Create widgets:
1852+
frame_shell = LabelFrame(self, borderwidth=2, relief=GROOVE,
1853+
text=' Shell Preferences')
1854+
frame_editor = LabelFrame(self, borderwidth=2, relief=GROOVE,
1855+
text=' Editor Preferences')
1856+
# Frame_shell.
1857+
frame_auto_squeeze_min_lines = Frame(frame_shell, borderwidth=0)
1858+
auto_squeeze_min_lines_title = Label(frame_auto_squeeze_min_lines,
1859+
text='Auto-Squeeze Min. Lines:')
1860+
self.auto_squeeze_min_lines_int = Entry(
1861+
frame_auto_squeeze_min_lines, width=4,
1862+
textvariable=self.auto_squeeze_min_lines,
1863+
validatecommand=self.digits_only, validate='key',
1864+
)
1865+
# Frame_editor.
1866+
frame_save = Frame(frame_editor, borderwidth=0)
1867+
run_save_title = Label(frame_save, text='At Start of Run (F5) ')
1868+
1869+
self.save_ask_on = Radiobutton(
1870+
frame_save, variable=self.autosave, value=0,
1871+
text="Prompt to Save")
1872+
self.save_auto_on = Radiobutton(
1873+
frame_save, variable=self.autosave, value=1,
1874+
text='No Prompt')
1875+
1876+
frame_line_numbers_default = Frame(frame_editor, borderwidth=0)
1877+
line_numbers_default_title = Label(
1878+
frame_line_numbers_default, text='Show line numbers in new windows')
1879+
self.line_numbers_default_bool = Checkbutton(
1880+
frame_line_numbers_default,
1881+
variable=self.line_numbers_default,
1882+
width=1)
1883+
1884+
frame_context = Frame(frame_editor, borderwidth=0)
1885+
context_title = Label(frame_context, text='Max Context Lines :')
1886+
self.context_int = Entry(
1887+
frame_context, textvariable=self.context_lines, width=3,
1888+
validatecommand=self.digits_only, validate='key',
1889+
)
1890+
1891+
# Pack widgets:
1892+
frame_shell.pack(side=TOP, padx=5, pady=5, fill=BOTH)
1893+
Label(self).pack() # Spacer -- better solution?
1894+
frame_editor.pack(side=TOP, padx=5, pady=5, fill=BOTH)
1895+
# frame_auto_squeeze_min_lines
1896+
frame_auto_squeeze_min_lines.pack(side=TOP, padx=5, pady=0, fill=X)
1897+
auto_squeeze_min_lines_title.pack(side=LEFT, anchor=W, padx=5, pady=5)
1898+
self.auto_squeeze_min_lines_int.pack(side=TOP, padx=5, pady=5)
1899+
# frame_save.
1900+
frame_save.pack(side=TOP, padx=5, pady=0, fill=X)
1901+
run_save_title.pack(side=LEFT, anchor=W, padx=5, pady=5)
1902+
self.save_auto_on.pack(side=RIGHT, anchor=W, padx=5, pady=5)
1903+
self.save_ask_on.pack(side=RIGHT, anchor=W, padx=5, pady=5)
1904+
# frame_line_numbers_default.
1905+
frame_line_numbers_default.pack(side=TOP, padx=5, pady=0, fill=X)
1906+
line_numbers_default_title.pack(side=LEFT, anchor=W, padx=5, pady=5)
1907+
self.line_numbers_default_bool.pack(side=LEFT, padx=5, pady=5)
1908+
# frame_context.
1909+
frame_context.pack(side=TOP, padx=5, pady=0, fill=X)
1910+
context_title.pack(side=LEFT, anchor=W, padx=5, pady=5)
1911+
self.context_int.pack(side=TOP, padx=5, pady=5)
18901912

18911913
def load_shelled_cfg(self):
1914+
# Set variables for shell windows.
1915+
self.auto_squeeze_min_lines.set(idleConf.GetOption(
1916+
'main', 'PyShell', 'auto-squeeze-min-lines', type='int'))
18921917
# Set variables for editor windows.
18931918
self.autosave.set(idleConf.GetOption(
18941919
'main', 'General', 'autosave', default=0, type='bool'))
1895-
self.format_width.set(idleConf.GetOption(
1896-
'extensions', 'FormatParagraph', 'max-width', type='int'))
18971920
self.line_numbers_default.set(idleConf.GetOption(
18981921
'main', 'EditorWindow', 'line-numbers-default', type='bool'))
18991922
self.context_lines.set(idleConf.GetOption(
19001923
'extensions', 'CodeContext', 'maxlines', type='int'))
19011924

1902-
# Set variables for shell windows.
1903-
self.auto_squeeze_min_lines.set(idleConf.GetOption(
1904-
'main', 'PyShell', 'auto-squeeze-min-lines', type='int'))
1905-
19061925

19071926
class ExtPage(Frame):
19081927
def __init__(self, master):

0 commit comments

Comments
 (0)