wx, python, and apple events

15 views
Skip to first unread message

Rohan

unread,
Sep 2, 2009, 11:05:05 AM9/2/09
to wxpytho...@lists.wxwidgets.org
Hi all,

I have run into a bit of a wall with this.

Scenario:
Our wx app is running on a mac, yeay! I have it running in the
background while I wait for it to do something or other.

In the meantime I download a file, and as our app is registered for
that file type I choose the option to open the file with our app.

When the download is complete, our app is raised, but nothing
happens. This is because I do not know how to make wxpython handle
this event on the mac. I need to be able to capture the event, and
have access to the information that was passed with it.

Postscript:
If the application is not open when the browser tries to start the
app, everything works perfectly, so the mechanism is working in the
application, and one idea on capturing the event is to spawn another
instance and pass through the parameters.

Thanks for any help or pointers to information on this. The python
mac stuff seems very out of date, and even the external link to Apple
documentation on the "Optimizing for the mac" page on the wiki, is so
old as to no longer exist, although for other things it was very
helpful.

Rohan


Cody Precord

unread,
Sep 2, 2009, 1:24:46 PM9/2/09
to wxpytho...@googlegroups.com
Hi,

On Wed, Sep 2, 2009 at 10:05 AM, Rohan<ro...@perzonae.com> wrote:
>
> Hi all,
>
> I have run into a bit of a wall with this.
>
> Scenario:
> Our wx app is running on a mac, yeay!  I have it running in the
> background while I wait for it to do something or other.
>
> In the meantime I download a file, and as our app is registered for
> that file type I choose the option to open the file with our app.
>
> When the download is complete, our app is raised, but nothing
> happens. This is because I do not know how to make wxpython handle
> this event on the mac.  I need to be able to capture the event, and
> have access to the information that was passed with it.

There is some builtin support for some apple events in the wxApp
object, that can be used by overriding the following virtual
functions.

def MacOpenFile(self, filename):
def MacNewFile(self):
def MacReopenApp(self): "kAEReopenApplication" event
def MacPrintFile(self, filename):

From your description you probably need to override MacOpenFile. If
not please specify what apple event you are trying to interact with,
it may be necessary to write a c extension to handle it if its not one
of the above events.


Cody

Christopher Barker

unread,
Sep 2, 2009, 1:38:06 PM9/2/09
to wxpytho...@googlegroups.com
Rohan wrote:
> Scenario:
> Our wx app is running on a mac, yeay! I have it running in the
> background while I wait for it to do something or other.
>
> In the meantime I download a file, and as our app is registered for
> that file type I choose the option to open the file with our app.
>
> When the download is complete, our app is raised, but nothing
> happens. This is because I do not know how to make wxpython handle
> this event on the mac. I need to be able to capture the event, and
> have access to the information that was passed with it.

Have you defined a MacOpenFile() method in your wx.App, as shown in:

http://wiki.wxpython.org/Optimizing%20for%20Mac%20OS%20X

That should take care if this use case.

> The python
> mac stuff seems very out of date, and even the external link to Apple
> documentation on the "Optimizing for the mac" page on the wiki, is so
> old as to no longer exist,

It's a Wiki -- it would be great if you could correct that link!

-Chris

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris....@noaa.gov

Rohan

unread,
Sep 7, 2009, 6:08:33 AM9/7/09
to wxpytho...@googlegroups.com
Christopher Barker wrote:
> Rohan wrote:
>> Scenario:
>> Our wx app is running on a mac, yeay! I have it running in the
>> background while I wait for it to do something or other.
>>
>> In the meantime I download a file, and as our app is registered for
>> that file type I choose the option to open the file with our app.
>>
>> When the download is complete, our app is raised, but nothing
>> happens. This is because I do not know how to make wxpython handle
>> this event on the mac. I need to be able to capture the event, and
>> have access to the information that was passed with it.
>
> Have you defined a MacOpenFile() method in your wx.App, as shown in:
>
> http://wiki.wxpython.org/Optimizing%20for%20Mac%20OS%20X
>
> That should take care if this use case.

Thanks, the MacOpenFile did indeed take care of it. I had implemented it
in a class that was then inherited by the various App objects in the
application. This did not work. The MacOpenFile must be coded in
the App object directly. I should add this to the wiki as well.

>
>> The python
>> mac stuff seems very out of date, and even the external link to Apple
>> documentation on the "Optimizing for the mac" page on the wiki, is so
>> old as to no longer exist,
>
> It's a Wiki -- it would be great if you could correct that link!

I corrected a previous one, and have done my best with the this one,
but was not sure if it was the correct place, but was where googling the
text of the link took me. :)

Thanks for all the help everyone. The application is up and running
functionally on a mac as well.

Rohan

Christopher Barker

unread,
Sep 8, 2009, 2:18:03 PM9/8/09
to wxpytho...@googlegroups.com
Rohan wrote:

> Christopher Barker wrote:
> Thanks, the MacOpenFile did indeed take care of it. I had implemented it
> in a class that was then inherited by the various App objects in the
> application.

I'm confused -- you can only have one wx.App running anyway -- why would
you have various wx.App objects?

> This did not work. The MacOpenFile must be coded in
> the App object directly. I should add this to the wiki as well.

yes, please do.

Reply all
Reply to author
Forward
0 new messages