bpo-37177: make IDLE's search dialogs transient (GH-13869) · python/cpython@295fe32

3 files changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -4,7 +4,7 @@

44
55

import unittest

66

from test.support import requires

7-

from tkinter import Tk

7+

from tkinter import Text, Tk, Toplevel

88

from tkinter.ttk import Frame

99

from idlelib import searchengine as se

1010

from idlelib import searchbase as sdb

@@ -47,14 +47,15 @@ def test_open_and_close(self):

4747

# open calls create_widgets, which needs default_command

4848

self.dialog.default_command = None

4949
50-

# Since text parameter of .open is not used in base class,

51-

# pass dummy 'text' instead of tk.Text().

52-

self.dialog.open('text')

50+

toplevel = Toplevel(self.root)

51+

self.addCleanup(toplevel.destroy)

52+

text = Text(toplevel)

53+

self.dialog.open(text)

5354

self.assertEqual(self.dialog.top.state(), 'normal')

5455

self.dialog.close()

5556

self.assertEqual(self.dialog.top.state(), 'withdrawn')

5657
57-

self.dialog.open('text', searchphrase="hello")

58+

self.dialog.open(text, searchphrase="hello")

5859

self.assertEqual(self.dialog.ent.get(), 'hello')

5960

self.dialog.close()

6061
Original file line numberDiff line numberDiff line change

@@ -54,6 +54,7 @@ def open(self, text, searchphrase=None):

5454

else:

5555

self.top.deiconify()

5656

self.top.tkraise()

57+

self.top.transient(text.winfo_toplevel())

5758

if searchphrase:

5859

self.ent.delete(0,"end")

5960

self.ent.insert("end",searchphrase)

@@ -66,6 +67,7 @@ def close(self, event=None):

6667

"Put dialog away for later use."

6768

if self.top:

6869

self.top.grab_release()

70+

self.top.transient('')

6971

self.top.withdraw()

7072
7173

def create_widgets(self):

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.