How to keep a Tkinter-Dialog on top of all other windows?

Joe Fromm jfromm at
Wed Jul 2 15:04:12 CEST 2003

"Thomas Nücker" <thomas.nuecker at> wrote in message
news:4b66f6d2.0307020435.345ff4f1 at
> Hi!
> I am creating a dialog-box within my application, using tkinter. The
> problem is the following: After the dialogbox is started, the main
> application window comes again to top and the dialogbox is covered by
> the window of the main application and must be "fetched" again via the
> taskbar to continue. Is there a way to "force" the dialogbox on top of
> all other windows? (I'm using MSWindows and Python22)

I had a similar problem using Python/tkinter embedded in a Win32 app, and
never found a truly satisfactory solution. The best I was able to do was
have the tk window call into my app, passing its window handle (which you
can get via winfo_id()).  In my app I have a timer running - as long as that
window exists it will keep calling SetWindowPos with the HWND_TOP flag to
move the Tk window on top of all the app windows.  When given the Tk window
handle you need to hunt up through it's parents until you find a window with
no parent, and call SetWindowPos on that window.

If the window being watched no longer exists I just kill the timer and clear
the window handle.

I'd love to find a solution that isn't such a grotesque hack.

Joe Fromm

More information about the Python-list mailing list