8000 [2.7] bpo-37177: make IDLE's search dialogs transient (GH-13869) · python/cpython@1b57ab5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1b57ab5

Browse files
authored
[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 554450f)
1 parent 20093b3 commit 1b57ab5

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

Lib/idlelib/SearchDialogBase.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def open(self, text, searchphrase=None):
5252
else:
5353
self.top.deiconify()
5454
self.top.tkraise()
55+
self.top.transient(text.winfo_toplevel())
5556
if searchphrase:
5657
self.ent.delete(0,"end")
5758
self.ent.insert("end",searchphrase)
@@ -64,6 +65,7 @@ def close(self, event=None):
6465
"Put dialog away for later use."
6566
if self.top:
6667
self.top.grab_release()
68+
self.top.transient('')
6769
self.top.withdraw()
6870

6971
def create_widgets(self):

Lib/idlelib/idle_test/test_searchdialogbase.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
'''
77
import unittest
88
from test.test_support import requires
9-
from Tkinter import Tk, Toplevel, Frame ## BooleanVar, StringVar
9+
from Tkinter import Text, Tk, Toplevel, Frame ## BooleanVar, StringVar
1010
from idlelib import SearchEngine as se
1111
from idlelib import SearchDialogBase as sdb
1212
from idlelib.idle_test.mock_idle import Func
@@ -45,14 +45,15 @@ def test_open_and_close(self):
4545
# open calls create_widgets, which needs default_command
4646
self.dialog.default_command = None
4747

48-
# Since text parameter of .open is not used in base class,
49-
# pass dummy 'text' instead of tk.Text().
50-
self.dialog.open('text')
48+
toplevel = Toplevel(self.root)
49+
self.addCleanup(toplevel.destroy)
50+
text = Text(toplevel)
51+
self.dialog.open(text)
5152
self.assertEqual(self.dialog.top.state(), 'normal')
5253
self.dialog.close()
5354
self.assertEqual(self.dialog.top.state(), 'withdrawn')
5455

55-
self.dialog.open('text', searchphrase="hello")
56+
self.dialog.open(text, searchphrase="hello")
5657
self.assertEqual(self.dialog.ent.get(), 'hello')
5758
self.dialog.close()
5859

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Properly 'attach' search dialogs to their main window so that they behave
2+
like other dialogs and do not get hidden behind their main window.

0 commit comments

Comments
 (0)
0