Here is a windows solution that uses FlashWindowExfrom dll user32. You need to pass the object FLASHWINFO. grab_setensures that the pop-up window remains in focus and disables any widgets in the main window, which makes the transition time of the pop-up window always at the top of the wizard. The event is <Button-1>used to check mouse clicks, and winfo_containingchecks whether another window has clicked, except for the pop-up window. Then I set the focus back to the popup and lock the window in focus (which is always a popup).
pywin32, .
import Tkinter as tk
from ctypes import *
import win32con
class popup(object):
def __init__(self, parent):
self.parent = parent
self.root=tk.Toplevel(self.parent)
self.root.title("Popup")
self.root.grab_set()
self.root.transient(self.parent)
self.root.bind("<Button-1>", self.flash)
def flash(self, event):
if self.root.winfo_containing(event.x_root, event.y_root)!=self.root:
self.root.focus_set()
number_of_flashes = 5
flash_time = 80
info = FLASHWINFO(0,
windll.user32.GetForegroundWindow(),
win32con.FLASHW_ALL,
number_of_flashes,
flash_time)
info.cbSize = sizeof(info)
windll.user32.FlashWindowEx(byref(info))
class FLASHWINFO(Structure):
_fields_ = [('cbSize', c_uint),
('hwnd', c_uint),
('dwFlags', c_uint),
('uCount', c_uint),
('dwTimeout', c_uint)]
main = tk.Tk()
main.title("Main")
pop = popup(main)
main.mainloop()
, , . , , , <FocusOut>, , , , , grab_set. , , . , , .