bpo-33987: Add master ttk Frame to IDLE search dialogs (GH-22942)

This commit is contained in:
Mark Roseman 2020-10-24 20:14:02 -07:00 committed by GitHub
parent 48be6b1ef7
commit 5df6c99cb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 14 deletions

View File

@ -3,6 +3,9 @@ Released on 2021-10-04?
======================================
bpo-33987: Mostly finish using ttk widgets, mainly for editor,
settings, and searches. Some patches by Mark Roseman.
bpo-41775: Make 'IDLE Shell' the shell title.
bpo-35764: Rewrite the Calltips doc section.

View File

@ -76,7 +76,7 @@ class SearchDialogBaseTest(unittest.TestCase):
def test_make_entry(self):
equal = self.assertEqual
self.dialog.row = 0
self.dialog.top = self.root
self.dialog.frame = Frame(self.root)
entry, label = self.dialog.make_entry("Test:", 'hello')
equal(label['text'], 'Test:')
@ -89,7 +89,7 @@ class SearchDialogBaseTest(unittest.TestCase):
equal(self.dialog.row, 1)
def test_create_entries(self):
self.dialog.top = self.root
self.dialog.frame = Frame(self.root)
self.dialog.row = 0
self.engine.setpat('hello')
self.dialog.create_entries()
@ -97,7 +97,7 @@ class SearchDialogBaseTest(unittest.TestCase):
def test_make_frame(self):
self.dialog.row = 0
self.dialog.top = self.root
self.dialog.frame = Frame(self.root)
frame, label = self.dialog.make_frame()
self.assertEqual(label, '')
self.assertEqual(str(type(frame)), "<class 'tkinter.ttk.Frame'>")
@ -108,7 +108,7 @@ class SearchDialogBaseTest(unittest.TestCase):
self.assertEqual(label['text'], 'testlabel')
def btn_test_setup(self, meth):
self.dialog.top = self.root
self.dialog.frame = Frame(self.root)
self.dialog.row = 0
return meth()
@ -140,13 +140,13 @@ class SearchDialogBaseTest(unittest.TestCase):
self.assertEqual(var.get(), state)
def test_make_button(self):
self.dialog.top = self.root
self.dialog.buttonframe = Frame(self.dialog.top)
self.dialog.frame = Frame(self.root)
self.dialog.buttonframe = Frame(self.dialog.frame)
btn = self.dialog.make_button('Test', self.dialog.close)
self.assertEqual(btn['text'], 'Test')
def test_create_command_buttons(self):
self.dialog.top = self.root
self.dialog.frame = Frame(self.root)
self.dialog.create_command_buttons()
# Look for close button command in buttonframe
closebuttoncommand = ''

View File

@ -33,6 +33,7 @@ class SearchDialogBase:
'''Initialize root, engine, and top attributes.
top (level widget): set in create_widgets() called from open().
frame: container for all widgets in dialog.
text (Text searched): set in open(), only used in subclasses().
ent (ry): created in make_entry() called from create_entry().
row (of grid): 0 in create_widgets(), +1 in make_entry/frame().
@ -83,10 +84,14 @@ class SearchDialogBase:
top.wm_title(self.title)
top.wm_iconname(self.icon)
self.top = top
self.frame = Frame(top, padding="5px")
self.frame.grid(sticky="nwes")
top.grid_columnconfigure(0, weight=100)
top.grid_rowconfigure(0, weight=100)
self.row = 0
self.top.grid_columnconfigure(0, pad=2, weight=0)
self.top.grid_columnconfigure(1, pad=2, minsize=100, weight=100)
self.frame.grid_columnconfigure(0, pad=2, weight=0)
self.frame.grid_columnconfigure(1, pad=2, minsize=100, weight=100)
self.create_entries() # row 0 (and maybe 1), cols 0, 1
self.create_option_buttons() # next row, cols 0, 1
@ -99,9 +104,9 @@ class SearchDialogBase:
entry - gridded labeled Entry for text entry.
label - Label widget, returned for testing.
'''
label = Label(self.top, text=label_text)
label = Label(self.frame, text=label_text)
label.grid(row=self.row, column=0, sticky="nw")
entry = Entry(self.top, textvariable=var, exportselection=0)
entry = Entry(self.frame, textvariable=var, exportselection=0)
entry.grid(row=self.row, column=1, sticky="nwe")
self.row = self.row + 1
return entry, label
@ -117,11 +122,11 @@ class SearchDialogBase:
label - Label widget, returned for testing.
'''
if labeltext:
label = Label(self.top, text=labeltext)
label = Label(self.frame, text=labeltext)
label.grid(row=self.row, column=0, sticky="nw")
else:
label = ''
frame = Frame(self.top)
frame = Frame(self.frame)
frame.grid(row=self.row, column=1, columnspan=1, sticky="nwe")
self.row = self.row + 1
return frame, label
@ -171,7 +176,7 @@ class SearchDialogBase:
def create_command_buttons(self):
"Place buttons in vertical command frame gridded on right."
f = self.buttonframe = Frame(self.top)
f = self.buttonframe = Frame(self.frame)
f.grid(row=0,column=2,padx=2,pady=2,ipadx=2,ipady=2)
b = self.make_button("Close", self.close)

View File

@ -0,0 +1,3 @@
Mostly finish using ttk widgets, mainly for editor, settings,
and searches. Some patches by Mark Roseman.