From 5df6c99cb450fe2f30be681dbf68cd1d34d3bbe4 Mon Sep 17 00:00:00 2001 From: Mark Roseman Date: Sat, 24 Oct 2020 20:14:02 -0700 Subject: [PATCH] bpo-33987: Add master ttk Frame to IDLE search dialogs (GH-22942) --- Lib/idlelib/NEWS.txt | 3 +++ Lib/idlelib/idle_test/test_searchbase.py | 14 +++++++------- Lib/idlelib/searchbase.py | 19 ++++++++++++------- .../2020-10-24-21-27-37.bpo-33987.fIh9JL.rst | 3 +++ 4 files changed, 25 insertions(+), 14 deletions(-) create mode 100644 Misc/NEWS.d/next/IDLE/2020-10-24-21-27-37.bpo-33987.fIh9JL.rst diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt index 754034200a1..3ece623b3aa 100644 --- a/Lib/idlelib/NEWS.txt +++ b/Lib/idlelib/NEWS.txt @@ -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. diff --git a/Lib/idlelib/idle_test/test_searchbase.py b/Lib/idlelib/idle_test/test_searchbase.py index aee0c4c6992..8c9c410ebaf 100644 --- a/Lib/idlelib/idle_test/test_searchbase.py +++ b/Lib/idlelib/idle_test/test_searchbase.py @@ -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)), "") @@ -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 = '' diff --git a/Lib/idlelib/searchbase.py b/Lib/idlelib/searchbase.py index 6fba0b8e583..fbef87aa2d3 100644 --- a/Lib/idlelib/searchbase.py +++ b/Lib/idlelib/searchbase.py @@ -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) diff --git a/Misc/NEWS.d/next/IDLE/2020-10-24-21-27-37.bpo-33987.fIh9JL.rst b/Misc/NEWS.d/next/IDLE/2020-10-24-21-27-37.bpo-33987.fIh9JL.rst new file mode 100644 index 00000000000..1e67edc03c6 --- /dev/null +++ b/Misc/NEWS.d/next/IDLE/2020-10-24-21-27-37.bpo-33987.fIh9JL.rst @@ -0,0 +1,3 @@ +Mostly finish using ttk widgets, mainly for editor, settings, +and searches. Some patches by Mark Roseman. +