diff -r 30b6cd2b3440 Lib/idlelib/dynoption.py --- a/Lib/idlelib/dynoption.py Mon Jun 20 14:13:12 2016 +0200 +++ b/Lib/idlelib/dynoption.py Mon Jun 20 17:25:59 2016 +0300 @@ -36,7 +36,7 @@ class DynOptionMenu(OptionMenu): def _dyn_option_menu(parent): # htest # from tkinter import Toplevel - top = Toplevel() + top = Toplevel(parent) top.title("Tets dynamic option menu") top.geometry("200x100+%d+%d" % (parent.winfo_rootx() + 200, parent.winfo_rooty() + 150)) diff -r 30b6cd2b3440 Lib/idlelib/idle_test/htest.py --- a/Lib/idlelib/idle_test/htest.py Mon Jun 20 14:13:12 2016 +0200 +++ b/Lib/idlelib/idle_test/htest.py Mon Jun 20 17:25:59 2016 +0300 @@ -364,7 +364,7 @@ def run(*tests): test = getattr(mod, test_name) test_list.append((test_spec, test)) - test_name = tk.StringVar('') + test_name = tk.StringVar(root) callable_object = None test_kwds = None diff -r 30b6cd2b3440 Lib/idlelib/idle_test/test_searchbase.py --- a/Lib/idlelib/idle_test/test_searchbase.py Mon Jun 20 14:13:12 2016 +0200 +++ b/Lib/idlelib/idle_test/test_searchbase.py Mon Jun 20 17:25:59 2016 +0300 @@ -74,7 +74,7 @@ class SearchDialogBaseTest(unittest.Test def test_make_entry(self): equal = self.assertEqual self.dialog.row = 0 - self.dialog.top = Toplevel(self.root) + self.dialog.top = self.root entry, label = self.dialog.make_entry("Test:", 'hello') equal(label['text'], 'Test:') @@ -87,6 +87,7 @@ class SearchDialogBaseTest(unittest.Test equal(self.dialog.row, 1) def test_create_entries(self): + self.dialog.top = self.root self.dialog.row = 0 self.engine.setpat('hello') self.dialog.create_entries() @@ -94,7 +95,7 @@ class SearchDialogBaseTest(unittest.Test def test_make_frame(self): self.dialog.row = 0 - self.dialog.top = Toplevel(self.root) + self.dialog.top = self.root frame, label = self.dialog.make_frame() self.assertEqual(label, '') self.assertIsInstance(frame, Frame) @@ -104,7 +105,7 @@ class SearchDialogBaseTest(unittest.Test self.assertIsInstance(frame, Frame) def btn_test_setup(self, meth): - self.dialog.top = Toplevel(self.root) + self.dialog.top = self.root self.dialog.row = 0 return meth() @@ -145,12 +146,13 @@ class SearchDialogBaseTest(unittest.Test self.assertEqual(var.get(), state) def test_make_button(self): - self.dialog.top = Toplevel(self.root) + self.dialog.top = self.root self.dialog.buttonframe = Frame(self.dialog.top) 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.create_command_buttons() # Look for close button command in buttonframe closebuttoncommand = '' diff -r 30b6cd2b3440 Lib/idlelib/idle_test/test_text.py --- a/Lib/idlelib/idle_test/test_text.py Mon Jun 20 14:13:12 2016 +0200 +++ b/Lib/idlelib/idle_test/test_text.py Mon Jun 20 17:25:59 2016 +0300 @@ -1,17 +1,19 @@ -# Test mock_tk.Text class against tkinter.Text class by running same tests with both. +''' Test mock_tk.Text class against tkinter.Text class + +Run same tests with both by creating a mixin class. +''' import unittest from test.support import requires - from _tkinter import TclError class TextTest(object): + "Define items common to both sets of tests." - hw = 'hello\nworld' # usual initial insert after initialization + hw = 'hello\nworld' # Several tests insert this after after initialization. hwn = hw+'\n' # \n present at initialization, before insert - Text = None - def setUp(self): - self.text = self.Text() + # setUpClass defines cls.Text and maybe cls.root. + # setUp defines self.text from Text and maybe root. def test_init(self): self.assertEqual(self.text.get('1.0'), '\n') @@ -196,6 +198,10 @@ class MockTextTest(TextTest, unittest.Te from idlelib.idle_test.mock_tk import Text cls.Text = Text + def setUp(self): + self.text = self.Text() + + def test_decode(self): # test endflags (-1, 0) not tested by test_index (which uses +1) decode = self.text._decode @@ -222,6 +228,9 @@ class TkTextTest(TextTest, unittest.Test cls.root.destroy() del cls.root + def setUp(self): + self.text = self.Text(self.root) + if __name__ == '__main__': unittest.main(verbosity=2, exit=False) diff -r 30b6cd2b3440 Lib/idlelib/percolator.py --- a/Lib/idlelib/percolator.py Mon Jun 20 14:13:12 2016 +0200 +++ b/Lib/idlelib/percolator.py Mon Jun 20 17:25:59 2016 +0300 @@ -89,10 +89,10 @@ def _percolator(parent): # htest # (pin if var2.get() else pout)(t2) text.pack() - var1 = tk.IntVar() + var1 = tk.IntVar(parent) cb1 = tk.Checkbutton(box, text="Tracer1", command=toggle1, variable=var1) cb1.pack() - var2 = tk.IntVar() + var2 = tk.IntVar(parent) cb2 = tk.Checkbutton(box, text="Tracer2", command=toggle2, variable=var2) cb2.pack() diff -r 30b6cd2b3440 Lib/idlelib/pyshell.py --- a/Lib/idlelib/pyshell.py Mon Jun 20 14:13:12 2016 +0200 +++ b/Lib/idlelib/pyshell.py Mon Jun 20 17:25:59 2016 +0300 @@ -2,6 +2,7 @@ try: from tkinter import * + # NoDefaultRoot() # More testing is needed for permanent uncomment. except ImportError: print("** IDLE can't import Tkinter.\n" "Your Python may not be configured for Tk. **", file=sys.__stderr__) @@ -1560,7 +1561,8 @@ def main(): ext = '.png' if TkVersion >= 8.6 else '.gif' iconfiles = [os.path.join(icondir, 'idle_%d%s' % (size, ext)) for size in (16, 32, 48)] - icons = [PhotoImage(file=iconfile) for iconfile in iconfiles] + icons = [PhotoImage(master=root, file=iconfile) + for iconfile in iconfiles] root.wm_iconphoto(True, *icons) fixwordbreaks(root) diff -r 30b6cd2b3440 Lib/idlelib/undo.py --- a/Lib/idlelib/undo.py Mon Jun 20 14:13:12 2016 +0200 +++ b/Lib/idlelib/undo.py Mon Jun 20 17:25:59 2016 +0300 @@ -341,7 +341,7 @@ def _undo_delegator(parent): # htest # import re import tkinter as tk from idlelib.percolator import Percolator - undowin = tk.Toplevel() + undowin = tk.Toplevel(parent) undowin.title("Test UndoDelegator") width, height, x, y = list(map(int, re.split('[x+]', parent.geometry()))) undowin.geometry("+%d+%d"%(x, y + 150)) diff -r 30b6cd2b3440 Lib/test/test_idle.py --- a/Lib/test/test_idle.py Mon Jun 20 14:13:12 2016 +0200 +++ b/Lib/test/test_idle.py Mon Jun 20 17:25:59 2016 +0300 @@ -6,6 +6,7 @@ import_module('threading') # imported b tk = import_module('tkinter') # imports _tkinter if tk.TkVersion < 8.5: raise unittest.SkipTest("IDLE requires tk 8.5 or later.") +tk.NoDefaultRoot() idletest = import_module('idlelib.idle_test') # Without test_main present, regrtest.runtest_inner (line1219) calls