Windows - getting Tkinter or wxPython window handle?

Myles myles at geocities.dot.com
Mon Jun 23 00:00:40 EDT 2003


Greg Ewing (using news.cis.dfn.de) wrote:
> On Windows, is there any chance of getting hold of an
> MFC window handle for a Tkinter or wxPython window?
> If so, how?

 > On Windows, is there any chance of getting hold of an
 > MFC window handle for a Tkinter or wxPython window?
 > If so, how?

wxWindow and its descendants have a GetHandle method.

"""
wxWindow::GetHandle
void* GetHandle() const

Returns the platform-specific handle of the physical window. Cast it to 
an appropriate handle, such as HWND for Windows, Widget for Motif or 
GtkWidget for GTK.

wxPython note: This method will return an integer in wxPython.
"""  -- extract from wxPython helpfile, Julian Smart, Robert Roebling, 
Vadim Zeitlin, Robin Dunn, et al

Within Tkinter, there is apparently an inner and outer window:

"""
you should be able to use wm_frame() (aka frame()) to
get hold of the outer window:

     inner = w.winfo_id()
     outer = string.atoi(w.wm_frame(), 0)

(wm_frame() returns the handle as a hex string).

Note that if the window hasn't been reparented by the
"window manager", both methods return the same window
handle.
""" -- extract from a posting by Fredrik Lundh

I hope this what you were after (I'm not familiar with "MFC handles")

Regards, Myles.





More information about the Python-list mailing list