You will need to provide some specifics of what you are using the
methods for but there are platform independent methods in wx itself
that perform the same task (depending upon the usage).
Hi,
I am porting a windows wxPython application to Mac OSX. Windows
version uses two win32gui methods.
Here are the methods I need:
win32gui.GetActiveWindow()
app = wx.GetApp()
app.GetTopWindow()
win32gui.EnumWindows(winHandler, topWindows)
windowList = wx.GetTopLevelWindows()
Cody
···
On Mon, Nov 29, 2010 at 12:56 PM, Fahri <mangabasi@gmail.com> wrote:
What are you using them for? Perhaps there is a wx way to do it that would not require calling native APIs. For example, to find the active frame in your application this would probably work:
for win in wx.GetTopLevelWindows():
if win.IsActive():
return win
return None
Any documentation performing these tasks on a Mac?
If you can find the API you need then you can use ctypes to call functions in the Carbon library. I expect that PyObjC could be used to call Cocoa methods in a Cocoa build of wx, but I've never tried it.
That isn't the same. GetTopWindow only returns the window you passed to SetTopWindow, or the first top-level window created if SetTopWindow wasn't called. If there is more than one top-level window in the application then that one may or may not be the active one.
···
On 11/29/10 11:02 AM, Cody Precord wrote:
Hi,
You will need to provide some specifics of what you are using the
methods for but there are platform independent methods in wx itself
that perform the same task (depending upon the usage).
On Mon, Nov 29, 2010 at 12:56 PM, Fahri<mangabasi@gmail.com> wrote:
Hi,
I am porting a windows wxPython application to Mac OSX. Windows
version uses two win32gui methods.
Thank you for your prompt reply. I am using these functions for the
"Auto Save" feature in my application. The way my scheme works I need
to get a list of all open windows to detect all running instances of
my application. AFAIK wx.GetTopLevelWindows() does not return all
open windows but only the ones belong to the application itself.
Since I am trying to detect multiple instances of my application this
doesn't help me. I think I need a native OS function for this. Since
I don't even know what it is called I am having difficulties searching
for it.
Fahri
···
On Nov 29, 2:02 pm, Cody Precord <codyprec...@gmail.com> wrote:
Hi,
You will need to provide some specifics of what you are using the
methods for but there are platform independent methods in wx itself
that perform the same task (depending upon the usage).
On Mon, Nov 29, 2010 at 12:56 PM, Fahri <mangab...@gmail.com> wrote:
> Hi,
> I am porting a windows wxPython application to Mac OSX. Windows
> version uses two win32gui methods.
That may not be an issue on the Mac as you should not have multiple instances of your application running. Instead Mac applications will typically have one or more document windows (wx.Frames) open, all of them running in the same process.
···
On 11/29/10 11:27 AM, Fahri wrote:
Hi Cody,
Thank you for your prompt reply. I am using these functions for the
"Auto Save" feature in my application. The way my scheme works I need
to get a list of all open windows to detect all running instances of
my application. AFAIK wx.GetTopLevelWindows() does not return all
open windows but only the ones belong to the application itself.
Since I am trying to detect multiple instances of my application this
doesn't help me. I think I need a native OS function for this. Since
I don't even know what it is called I am having difficulties searching
for it.
That isn't the same. GetTopWindow only returns the window you passed to
SetTopWindow, or the first top-level window created if SetTopWindow wasn't
called. If there is more than one top-level window in the application then
that one may or may not be the active one.
Forgot about that as I usually have a OnActivate handling in my base
toplevel window class that calls SetTopWindow.
Something along the following lines could be equivalent if the usage
is app centric:
def GetActiveWindow():
for win in wx.GetTopLevelWindows():
if getattr(win, 'IsActive', lamba:False)():
return win
Cody
···
On Mon, Nov 29, 2010 at 1:24 PM, Robin Dunn <robin@alldunn.com> wrote:
The difficult part for me is not getting the handler of the active
window but getting a list of all open windows' handlers. As I wrote
in my reply to Cody's reply I need this for my "Auto Save" feature. I
guess there are other ways I can handle auto-saving but since the
current implementation has been tested and functioning well, I would
like to port it as is.
If I can find the Carbon equivalent of win32gui.EnumWindows then I can
call it with Ctypes as you recommended. Maybe someone already knows
what this function is called in Carbon, if not I will have to dig
deeper.
Fahri
···
On Nov 29, 2:24 pm, Robin Dunn <ro...@alldunn.com> wrote:
On 11/29/10 10:56 AM, Fahri wrote:
> Hi,
> I am porting a windows wxPython application to Mac OSX. Windows
> version uses two win32gui methods.
What are you using them for? Perhaps there is a wx way to do it that
would not require calling native APIs. For example, to find the active
frame in your application this would probably work:
for win in wx\.GetTopLevelWindows\(\):
if win\.IsActive\(\):
return win
return None
> Any documentation performing these tasks on a Mac?
If you can find the API you need then you can use ctypes to call
functions in the Carbon library. I expect that PyObjC could be used to
call Cocoa methods in a Cocoa build of wx, but I've never tried it.
--
Robin Dunn
Software Craftsmanhttp://wxPython.org
If that's the case then I may not even need the win32gui.EnumWindows.
I will test this now.
Thanks,
Fahri
···
That may not be an issue on the Mac as you should not have multiple
instances of your application running. Instead Mac applications will
typically have one or more document windows (wx.Frames) open, all of
them running in the same process.
--
Robin Dunn
Software Craftsmanhttp://wxPython.org