Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5df6c99

Browse files
authored
bpo-33987: Add master ttk Frame to IDLE search dialogs (GH-22942)
1 parent 48be6b1 commit 5df6c99

File tree

4 files changed

+25
-14
lines changed

4 files changed

+25
-14
lines changed

Lib/idlelib/NEWS.txt

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ Released on 2021-10-04?
33
======================================
44

55

6+
bpo-33987: Mostly finish using ttk widgets, mainly for editor,
7+
settings, and searches. Some patches by Mark Roseman.
8+
69
bpo-41775: Make 'IDLE Shell' the shell title.
710

811
bpo-35764: Rewrite the Calltips doc section.

Lib/idlelib/idle_test/test_searchbase.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def test_create_widgets(self):
7676
def test_make_entry(self):
7777
equal = self.assertEqual
7878
self.dialog.row = 0
79-
self.dialog.top = self.root
79+
self.dialog.frame = Frame(self.root)
8080
entry, label = self.dialog.make_entry("Test:", 'hello')
8181
equal(label['text'], 'Test:')
8282

@@ -89,15 +89,15 @@ def test_make_entry(self):
8989
equal(self.dialog.row, 1)
9090

9191
def test_create_entries(self):
92-
self.dialog.top = self.root
92+
self.dialog.frame = Frame(self.root)
9393
self.dialog.row = 0
9494
self.engine.setpat('hello')
9595
self.dialog.create_entries()
9696
self.assertIn(self.dialog.ent.get(), 'hello')
9797

9898
def test_make_frame(self):
9999
self.dialog.row = 0
100-
self.dialog.top = self.root
100+
self.dialog.frame = Frame(self.root)
101101
frame, label = self.dialog.make_frame()
102102
self.assertEqual(label, '')
103103
self.assertEqual(str(type(frame)), "<class 'tkinter.ttk.Frame'>")
@@ -108,7 +108,7 @@ def test_make_frame(self):
108108
self.assertEqual(label['text'], 'testlabel')
109109

110110
def btn_test_setup(self, meth):
111-
self.dialog.top = self.root
111+
self.dialog.frame = Frame(self.root)
112112
self.dialog.row = 0
113113
return meth()
114114

@@ -140,13 +140,13 @@ def test_create_other_buttons(self):
140140
self.assertEqual(var.get(), state)
141141

142142
def test_make_button(self):
143-
self.dialog.top = self.root
144-
self.dialog.buttonframe = Frame(self.dialog.top)
143+
self.dialog.frame = Frame(self.root)
144+
self.dialog.buttonframe = Frame(self.dialog.frame)
145145
btn = self.dialog.make_button('Test', self.dialog.close)
146146
self.assertEqual(btn['text'], 'Test')
147147

148148
def test_create_command_buttons(self):
149-
self.dialog.top = self.root
149+
self.dialog.frame = Frame(self.root)
150150
self.dialog.create_command_buttons()
151151
# Look for close button command in buttonframe
152152
closebuttoncommand = ''

Lib/idlelib/searchbase.py

+12-7
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def __init__(self, root, engine):
3333
'''Initialize root, engine, and top attributes.
3434
3535
top (level widget): set in create_widgets() called from open().
36+
frame: container for all widgets in dialog.
3637
text (Text searched): set in open(), only used in subclasses().
3738
ent (ry): created in make_entry() called from create_entry().
3839
row (of grid): 0 in create_widgets(), +1 in make_entry/frame().
@@ -83,10 +84,14 @@ def create_widgets(self):
8384
top.wm_title(self.title)
8485
top.wm_iconname(self.icon)
8586
self.top = top
87+
self.frame = Frame(top, padding="5px")
88+
self.frame.grid(sticky="nwes")
89+
top.grid_columnconfigure(0, weight=100)
90+
top.grid_rowconfigure(0, weight=100)
8691

8792
self.row = 0
88-
self.top.grid_columnconfigure(0, pad=2, weight=0)
89-
self.top.grid_columnconfigure(1, pad=2, minsize=100, weight=100)
93+
self.frame.grid_columnconfigure(0, pad=2, weight=0)
94+
self.frame.grid_columnconfigure(1, pad=2, minsize=100, weight=100)
9095

9196
self.create_entries() # row 0 (and maybe 1), cols 0, 1
9297
self.create_option_buttons() # next row, cols 0, 1
@@ -99,9 +104,9 @@ def make_entry(self, label_text, var):
99104
entry - gridded labeled Entry for text entry.
100105
label - Label widget, returned for testing.
101106
'''
102-
label = Label(self.top, text=label_text)
107+
label = Label(self.frame, text=label_text)
103108
label.grid(row=self.row, column=0, sticky="nw")
104-
entry = Entry(self.top, textvariable=var, exportselection=0)
109+
entry = Entry(self.frame, textvariable=var, exportselection=0)
105110
entry.grid(row=self.row, column=1, sticky="nwe")
106111
self.row = self.row + 1
107112
return entry, label
@@ -117,11 +122,11 @@ def make_frame(self,labeltext=None):
117122
label - Label widget, returned for testing.
118123
'''
119124
if labeltext:
120-
label = Label(self.top, text=labeltext)
125+
label = Label(self.frame, text=labeltext)
121126
label.grid(row=self.row, column=0, sticky="nw")
122127
else:
123128
label = ''
124-
frame = Frame(self.top)
129+
frame = Frame(self.frame)
125130
frame.grid(row=self.row, column=1, columnspan=1, sticky="nwe")
126131
self.row = self.row + 1
127132
return frame, label
@@ -171,7 +176,7 @@ def make_button(self, label, command, isdef=0):
171176

172177
def create_command_buttons(self):
173178
"Place buttons in vertical command frame gridded on right."
174-
f = self.buttonframe = Frame(self.top)
179+
f = self.buttonframe = Frame(self.frame)
175180
f.grid(row=0,column=2,padx=2,pady=2,ipadx=2,ipady=2)
176181

177182
b = self.make_button("Close", self.close)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Mostly finish using ttk widgets, mainly for editor, settings,
2+
and searches. Some patches by Mark Roseman.
3+

0 commit comments

Comments
 (0)