[Python-checkins] [2.7] bpo-37177: make IDLE's search dialogs transient (GH-13869)

Tal Einat webhook-mailer at python.org
Fri Jun 7 02:53:09 EDT 2019


https://github.com/python/cpython/commit/1b57ab5c6478b93cf4150bd8c475022252776598
commit: 1b57ab5c6478b93cf4150bd8c475022252776598
branch: 2.7
author: Tal Einat <taleinat+github at gmail.com>
committer: GitHub <noreply at github.com>
date: 2019-06-07T09:53:05+03:00
summary:

[2.7] bpo-37177: make IDLE's search dialogs transient (GH-13869)

This avoids the search dialogs being hidden behind the editor window.

(cherry picked from commit 554450fb4e95066e825bdb4a2d544a490daeebdc)

files:
A Misc/NEWS.d/next/IDLE/2019-06-07-00-17-41.bpo-37177.voU6pQ.rst
M Lib/idlelib/SearchDialogBase.py
M Lib/idlelib/idle_test/test_searchdialogbase.py

diff --git a/Lib/idlelib/SearchDialogBase.py b/Lib/idlelib/SearchDialogBase.py
index 651e7f4a3fcd..9eb8b223ffda 100644
--- a/Lib/idlelib/SearchDialogBase.py
+++ b/Lib/idlelib/SearchDialogBase.py
@@ -52,6 +52,7 @@ def open(self, text, searchphrase=None):
         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)
@@ -64,6 +65,7 @@ def close(self, event=None):
         "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/Lib/idlelib/idle_test/test_searchdialogbase.py b/Lib/idlelib/idle_test/test_searchdialogbase.py
index 32abfe6f792d..7ca6bbf69347 100644
--- a/Lib/idlelib/idle_test/test_searchdialogbase.py
+++ b/Lib/idlelib/idle_test/test_searchdialogbase.py
@@ -6,7 +6,7 @@
 '''
 import unittest
 from test.test_support import requires
-from Tkinter import Tk, Toplevel, Frame ## BooleanVar, StringVar
+from Tkinter import Text, Tk, Toplevel, Frame ## BooleanVar, StringVar
 from idlelib import SearchEngine as se
 from idlelib import SearchDialogBase as sdb
 from idlelib.idle_test.mock_idle import Func
@@ -45,14 +45,15 @@ def test_open_and_close(self):
         # 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()
 
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
index 000000000000..74e48eef89a6
--- /dev/null
+++ b/Misc/NEWS.d/next/IDLE/2019-06-07-00-17-41.bpo-37177.voU6pQ.rst
@@ -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.



More information about the Python-checkins mailing list