Search code examples
pythonmacoswxpythonpyobjc

wxPython on Mac OS X: creating a wx.Frame without stealing focus


I managed to get it working on Win32 (inheriting from wx.MiniFrame does the trick), on wxGTK (wx.PopupWindow) but whatever I try, when I create a frame on wxMac, my main window loses focus and the new frame gets it.

wxMac does not seem to have a way to interact with the native platform (something like GetHandle() on Win32 and GetGTKWidget() on wxGTK), so I can't hack around it this way.

I managed to get this working in another situation, by creating the frame at startup and moving it outside of the display area, then moving it in a visible position when needed. But right now this would be cumbersome because I don't know in advance how many frames I will need.

So, any simpler way to do this ?


Solution

  • If you want to get native handle to window in Mac you can do

    frame.MacGetTopLevelWindowRef()
    

    and may be you can use pyobjc to interact with windows natively, but why don't you set focus on the window you want to after opening mini-frame?