]> granicus.if.org Git - python/commitdiff
bpo-37177: make IDLE's search dialogs transient (GH-13869)
authorTal Einat <taleinat@gmail.com>
Fri, 7 Jun 2019 05:54:40 +0000 (08:54 +0300)
committerGitHub <noreply@github.com>
Fri, 7 Jun 2019 05:54:40 +0000 (08:54 +0300)
This avoids the search dialogs being hidden behind the editor window.

Lib/idlelib/idle_test/test_searchbase.py
Lib/idlelib/searchbase.py
Misc/NEWS.d/next/IDLE/2019-06-07-00-17-41.bpo-37177.voU6pQ.rst [new file with mode: 0644]

index 6dd4d79337371d7ac3b03034eccdccdc5120fd21..e08268fde25799b68785bf547d70848d1e4ca8a2 100644 (file)
@@ -4,7 +4,7 @@
 
 import unittest
 from test.support import requires
-from tkinter import Tk
+from tkinter import Text, Tk, Toplevel
 from tkinter.ttk import Frame
 from idlelib import searchengine as se
 from idlelib import searchbase as sdb
@@ -47,14 +47,15 @@ class SearchDialogBaseTest(unittest.TestCase):
         # open calls create_widgets, which needs default_command
         self.dialog.default_command = None
 
-        # Since text parameter of .open is not used in base class,
-        # pass dummy 'text' instead of tk.Text().
-        self.dialog.open('text')
+        toplevel = Toplevel(self.root)
+        self.addCleanup(toplevel.destroy)
+        text = Text(toplevel)
+        self.dialog.open(text)
         self.assertEqual(self.dialog.top.state(), 'normal')
         self.dialog.close()
         self.assertEqual(self.dialog.top.state(), 'withdrawn')
 
-        self.dialog.open('text', searchphrase="hello")
+        self.dialog.open(text, searchphrase="hello")
         self.assertEqual(self.dialog.ent.get(), 'hello')
         self.dialog.close()
 
index 4ed94f186b048d16f33e873cd6014a595892aff4..6fba0b8e583f2b3d48574201459d3d1c360db6b2 100644 (file)
@@ -54,6 +54,7 @@ class SearchDialogBase:
         else:
             self.top.deiconify()
             self.top.tkraise()
+        self.top.transient(text.winfo_toplevel())
         if searchphrase:
             self.ent.delete(0,"end")
             self.ent.insert("end",searchphrase)
@@ -66,6 +67,7 @@ class SearchDialogBase:
         "Put dialog away for later use."
         if self.top:
             self.top.grab_release()
+            self.top.transient('')
             self.top.withdraw()
 
     def create_widgets(self):
diff --git a/Misc/NEWS.d/next/IDLE/2019-06-07-00-17-41.bpo-37177.voU6pQ.rst b/Misc/NEWS.d/next/IDLE/2019-06-07-00-17-41.bpo-37177.voU6pQ.rst
new file mode 100644 (file)
index 0000000..74e48ee
--- /dev/null
@@ -0,0 +1,2 @@
+Properly 'attach' search dialogs to their main window so that they behave
+like other dialogs and do not get hidden behind their main window.