Tkinter Window On Top

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Fri May 15 21:25:45 EDT 2009


En Fri, 15 May 2009 16:39:41 -0300, Trevor <trevor.lango at gmail.com>  
escribió:

> Can a Tkinter application create a COM object and keep its own window
> on top of it?
>
> excel = win32com.client.Dispatch('Excel.Application')
>
> I would like the user to be able to see and interact with the Excel
> application but keep the Tkinter application on top.

I don't know how to do that directly with tk, but I'd use the SetWindowPos  
function: http://msdn.microsoft.com/en-us/library/ms632673(VS.85).aspx
The tricky part is to get the right hwnd, this seems to work:

>>> root = Tkinter.Tk()
>>> hwnd = int(root.wm_frame(),0)
>>> win32gui.SetWindowPos(hwnd,
...   win32con.HWND_TOPMOST,
...   0,0,0,0,
...   win32con.SWP_NOMOVE | win32con.SWP_NOSIZE)

-- 
Gabriel Genellina




More information about the Python-list mailing list