"Mark Hammond" <[EMAIL PROTECTED]> writes: >> Does anyone know how to keep a tkinter window always on top, despite >> attempts to focus other windows? Here is my failed attempt. I've >> tried both tkinter-only and win32-specific solutions. For this code, >> the window does stay in front of the dos box it's launched from if I >> try to focus the dos box, but that's the only one it stays in front >> of. Thanks, Benjamin > > Try something like: > > import win32gui > win32gui.SetWindowPos(hWnd, win32con.HWND_TOPMOST, 0,0,0,0, > win32con.SWP_NOMOVE | win32con.SWP_NOSIZE)
Hmm, that didn't work either. Below is the full program I used. Do you think the fact that it's being run from a tkinter callback is why it isn't working? Like maybe tkinter is stealing/inhibiting these Windows API calls while it's running the callbacks? Running WinXP SP2, python 2.4.1, win32all build 204 here. #!/usr/bin/env python from Tkinter import * import win32ui, win32con, win32gui root = None reps = 0 def show(): hwnd = root.winfo_id() win32gui.SetWindowPos(hwnd, win32con.HWND_TOPMOST, 0,0,0,0, win32con.SWP_NOMOVE | win32con.SWP_NOSIZE) def reshow(): global reps reps += 1 print 'reshow(%d)' % (reps) show() if reps < 100: root.after(100, reshow) else: root.destroy() root = Tk() root.config(width=400, height=400) show() root.after(100, reshow) root.mainloop() _______________________________________________ Python-win32 mailing list [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/python-win32