8000 [2.7] bpo-37177: make IDLE's search dialogs transient (GH-13869) by taleinat · Pull Request #13880 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Lib/idlelib/SearchDialogBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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):
Expand Down
11 changes: 6 additions & 5 deletions Lib/idlelib/idle_test/test_searchdialogbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
0