bpo-37177: make IDLE's search dialogs transient (GH-13869)
This avoids the search dialogs being hidden behind the editor window.
This commit is contained in:
parent
de76c07a8c
commit
554450fb4e
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
from test.support import requires
|
from test.support import requires
|
||||||
from tkinter import Tk
|
from tkinter import Text, Tk, Toplevel
|
||||||
from tkinter.ttk import Frame
|
from tkinter.ttk import Frame
|
||||||
from idlelib import searchengine as se
|
from idlelib import searchengine as se
|
||||||
from idlelib import searchbase as sdb
|
from idlelib import searchbase as sdb
|
||||||
|
@ -47,14 +47,15 @@ class SearchDialogBaseTest(unittest.TestCase):
|
||||||
# open calls create_widgets, which needs default_command
|
# open calls create_widgets, which needs default_command
|
||||||
self.dialog.default_command = None
|
self.dialog.default_command = None
|
||||||
|
|
||||||
# Since text parameter of .open is not used in base class,
|
toplevel = Toplevel(self.root)
|
||||||
# pass dummy 'text' instead of tk.Text().
|
self.addCleanup(toplevel.destroy)
|
||||||
self.dialog.open('text')
|
text = Text(toplevel)
|
||||||
|
self.dialog.open(text)
|
||||||
self.assertEqual(self.dialog.top.state(), 'normal')
|
self.assertEqual(self.dialog.top.state(), 'normal')
|
||||||
self.dialog.close()
|
self.dialog.close()
|
||||||
self.assertEqual(self.dialog.top.state(), 'withdrawn')
|
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.assertEqual(self.dialog.ent.get(), 'hello')
|
||||||
self.dialog.close()
|
self.dialog.close()
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,7 @@ class SearchDialogBase:
|
||||||
else:
|
else:
|
||||||
self.top.deiconify()
|
self.top.deiconify()
|
||||||
self.top.tkraise()
|
self.top.tkraise()
|
||||||
|
self.top.transient(text.winfo_toplevel())
|
||||||
if searchphrase:
|
if searchphrase:
|
||||||
self.ent.delete(0,"end")
|
self.ent.delete(0,"end")
|
||||||
self.ent.insert("end",searchphrase)
|
self.ent.insert("end",searchphrase)
|
||||||
|
@ -66,6 +67,7 @@ class SearchDialogBase:
|
||||||
"Put dialog away for later use."
|
"Put dialog away for later use."
|
||||||
if self.top:
|
if self.top:
|
||||||
self.top.grab_release()
|
self.top.grab_release()
|
||||||
|
self.top.transient('')
|
||||||
self.top.withdraw()
|
self.top.withdraw()
|
||||||
|
|
||||||
def create_widgets(self):
|
def create_widgets(self):
|
||||||
|
|
|
@ -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.
|
Loading…
Reference in New Issue