8000 bpo-33987: IDLE - use ttk Frame for ttk widgets (GH-11395) · python/cpython@aff0ada · GitHub
[go: up one dir, main page]

Skip to content

Commit aff0ada

Browse files
authored
bpo-33987: IDLE - use ttk Frame for ttk widgets (GH-11395)
1 parent e9a044e commit aff0ada

13 files changed

+38
-28
lines changed

Lib/idlelib/autocomplete_w.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import platform
55

66
from tkinter import *
7-
from tkinter.ttk import Scrollbar
7+
from tkinter.ttk import Frame, Scrollbar
88

99
from idlelib.autocomplete import COMPLETE_FILES, COMPLETE_ATTRIBUTES
1010
from idlelib.multicall import MC_SHIFT

Lib/idlelib/config_key.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Dialog for building Tkinter accelerator key bindings
33
"""
44
from tkinter import Toplevel, Listbox, Text, StringVar, TclError
5-
from tkinter.ttk import Button, Checkbutton, Entry, Frame, Label, Scrollbar
5+
from tkinter.ttk import Frame, Button, Checkbutton, Entry, Label, Scrollbar
66
from tkinter import messagebox
77
import string
88
import sys

Lib/idlelib/configdialog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
TOP, BOTTOM, RIGHT, LEFT, SOLID, GROOVE,
1515
NONE, BOTH, X, Y, W, E, EW, NS, NSEW, NW,
1616
HORIZONTAL, VERTICAL, ANCHOR, ACTIVE, END)
17-
from tkinter.ttk import (Button, Checkbutton, Entry, Frame, Label, LabelFrame,
17+
from tkinter.ttk import (Frame, LabelFrame, Button, Checkbutton, Entry, Label,
1818
OptionMenu, Notebook, Radiobutton, Scrollbar, Style)
1919
import tkinter.colorchooser as tkColorChooser
2020
import tkinter.font as tkFont

Lib/idlelib/debugger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import os
33

44
from tkinter import *
5-
from tkinter.ttk import Scrollbar
5+
from tkinter.ttk import Frame, Scrollbar
66

77
from idlelib import macosx
88
from idlelib.scrolledlist import ScrolledList

Lib/idlelib/grep.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import sys
99

1010
from tkinter import StringVar, BooleanVar
11-
from tkinter.ttk import Checkbutton
11+
from tkinter.ttk import Checkbutton # Frame imported in ...Base
1212

1313
from idlelib.searchbase import SearchDialogBase
1414
from idlelib import searchengine
@@ -173,23 +173,26 @@ def findfiles(self, dir, base, rec):
173173

174174
def _grep_dialog(parent): # htest #
175175
from tkinter import Toplevel, Text, SEL, END
176-
from tkinter.ttk import Button
176+
from tkinter.ttk import Frame, Button
177177
from idlelib.pyshell import PyShellFileList
178+
178179
top = Toplevel(parent)
179180
top.title("Test GrepDialog")
180181
x, y = map(int, parent.geometry().split('+')[1:])
181182
top.geometry(f"+{x}+{y + 175}")
182183

183184
flist = PyShellFileList(top)
184-
text = Text(top, height=5)
185+
frame = Frame(top)
186+
frame.pack()
187+
text = Text(frame, height=5)
185188
text.pack()
186189

187190
def show_grep_dialog():
188191
text.tag_add(SEL, "1.0", END)
189192
grep(text, flist=flist)
190193
text.tag_remove(SEL, "1.0", END)
191194

192-
button = Button(top, text="Show GrepDialog", command=show_grep_dialog)
195+
button = Button(frame, text="Show GrepDialog", command=show_grep_dialog)
193196
button.pack()
194197

195198
if __name__ == "__main__":

Lib/idlelib/idle_test/test_searchbase.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
import unittest
66
from test.support import requires
7-
from tkinter import Tk, Frame ##, BooleanVar, StringVar
7+
from tkinter import Tk
8+
from tkinter.ttk import Frame
89
from idlelib import searchengine as se
910
from idlelib import searchbase as sdb
1011
from idlelib.idle_test.mock_idle import Func
@@ -97,11 +98,12 @@ def test_make_frame(self):
9798
self.dialog.top = self.root
9899
frame, label = self.dialog.make_frame()
99100
self.assertEqual(label, '')
100-
self.assertIsInstance(frame, Frame)
101+
self.assertEqual(str(type(frame)), "<class 'tkinter.ttk.Frame'>")
102+
# self.assertIsInstance(frame, Frame) fails when test is run by
103+
# test_idle not run from IDLE editor. See issue 33987 PR.
101104

102105
frame, label = self.dialog.make_frame('testlabel')
103106
self.assertEqual(label['text'], 'testlabel')
104-
self.assertIsInstance(frame, Frame)
105107

106108
def btn_test_setup(self, meth):
107109
self.dialog.top = self.root

Lib/idlelib/query.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""
22
Dialogs that query users and verify the answer before accepting.
3-
Use ttk widgets, limiting use to tcl/tk 8.5+, as in IDLE 3.6+.
43
54
Query is the generic base class for a popup dialog.
65
The user must either enter a valid answer or close the dialog.

Lib/idlelib/replace.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,12 @@ def close(self, event=None):
205205

206206
def _replace_dialog(parent): # htest #
207207
from tkinter import Toplevel, Text, END, SEL
208-
from tkinter.ttk import Button
208+
from tkinter.ttk import Frame, Button
209209

210-
box = Toplevel(parent)
211-
box.title("Test ReplaceDialog")
210+
top = Toplevel(parent)
211+
top.title("Test ReplaceDialog")
212212
x, y = map(int, parent.geometry().split('+')[1:])
213-
box.geometry("+%d+%d" % (x, y + 175))
213+
top.geometry("+%d+%d" % (x, y + 175))
214214

215215
# mock undo delegator methods
216216
def undo_block_start():
@@ -219,7 +219,9 @@ def undo_block_start():
219219
def undo_block_stop():
220220
pass
221221

222-
text = Text(box, inactiveselectbackground='gray')
222+
frame = Frame(top)
223+
frame.pack()
224+
text = Text(frame, inactiveselectbackground='gray')
223225
text.undo_block_start = undo_block_start
224226
text.undo_block_stop = undo_block_stop
225227
text.pack()
@@ -231,7 +233,7 @@ def show_replace():
231233
replace(text)
232234
text.tag_remove(SEL, "1.0", END)
233235

234-
button = Button(box, text="Replace", command=show_replace)
236+
button = Button(frame, text="Replace", command=show_replace)
235237
button.pack()
236238

237239
if __name__ == '__main__':

Lib/idlelib/scrolledlist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from tkinter import *
2-
from tkinter.ttk import Scrollbar
2+
from tkinter.ttk import Frame, Scrollbar
33

44
from idlelib import macosx
55

Lib/idlelib/search.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,16 @@ def find_selection(self, text):
7575
def _search_dialog(parent): # htest #
7676
"Display search test box."
7777
from tkinter import Toplevel, Text
78-
from tkinter.ttk import Button
78+
from tkinter.ttk import Frame, Button
7979

80-
box = Toplevel(parent)
81-
box.title("Test SearchDialog")
80+
top = Toplevel(parent)
81+
top.title("Test SearchDialog")
8282
x, y = map(int, parent.geometry().split('+')[1:])
83-
box.geometry("+%d+%d" % (x, y + 175))
84-
text = Text(box, inactiveselectbackground='gray')
83+
top.geometry("+%d+%d" % (x, y + 175))
84+
85+
frame = Frame(top)
86+
frame.pack()
87+
text = Text(frame, inactiveselectbackground='gray')
8588
text.pack()
8689
text.insert("insert","This is a sample string.\n"*5)
8790

@@ -90,7 +93,7 @@ def show_find():
9093
_setup(text).open(text)
9194
text.tag_remove('sel', '1.0', 'end')
9295

93-
button = Button(box, text="Search (selection ignored)", command=show_find)
96+
button = Button(frame, text="Search (selection ignored)", command=show_find)
9497
button.pack()
9598

9699
if __name__ == '__main__':

Lib/idlelib/searchbase.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'''Define SearchDialogBase used by Search, Replace, and Grep dialogs.'''
22

3-
from tkinter import Toplevel, Frame
4-
from tkinter.ttk import Entry, Label, Button, Checkbutton, Radiobutton
3+
from tkinter import Toplevel
4+
from tkinter.ttk import Frame, Entry, Label, Button, Checkbutton, Radiobutton
55

66

77
class SearchDialogBase:

Lib/idlelib/tree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import os
1818

1919
from tkinter import *
20-
from tkinter.ttk import Scrollbar
20+
from tkinter.ttk import Frame, Scrollbar
2121

2222
from idlelib.config import idleConf
2323
from idlelib import zoomheight
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Use ttk Frame for ttk widgets.

0 commit comments

Comments
 (0)
0