summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib
diff options
context:
space:
mode:
authorMark Roseman <mark@markroseman.com>2020-10-25 03:14:02 (GMT)
committerGitHub <noreply@github.com>2020-10-25 03:14:02 (GMT)
commit5df6c99cb450fe2f30be681dbf68cd1d34d3bbe4 (patch)
tree52e576ddcbf16d758e3ffbb34e152a671fb5bf38 /Lib/idlelib
parent48be6b1ef7a6201e13c87a317361cdb60bd5faa8 (diff)
downloadcpython-5df6c99cb450fe2f30be681dbf68cd1d34d3bbe4.zip
cpython-5df6c99cb450fe2f30be681dbf68cd1d34d3bbe4.tar.gz
cpython-5df6c99cb450fe2f30be681dbf68cd1d34d3bbe4.tar.bz2
bpo-33987: Add master ttk Frame to IDLE search dialogs (GH-22942)
Diffstat (limited to 'Lib/idlelib')
-rw-r--r--Lib/idlelib/NEWS.txt3
-rw-r--r--Lib/idlelib/idle_test/test_searchbase.py14
-rw-r--r--Lib/idlelib/searchbase.py19
3 files changed, 22 insertions, 14 deletions
diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt
index 7540342..3ece623 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 aee0c4c..8c9c410 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)), "<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 = ''
diff --git a/Lib/idlelib/searchbase.py b/Lib/idlelib/searchbase.py
index 6fba0b8..fbef87a 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)