MacOpenFile using sys.argv from command line with wx 2.9.x

I was trying to use MacOpenFile with 2.9.4, and cut the demo out of:

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

When testing by running from the command line, I get MacOpenFile
called for each of the command line arguments, e.g.:

python MacApp.py test1.txt test2.txt

it gets called for

MacApp.py
test1.txt
test2.txt

which doesn't happen with wx 2.8. Maybe the "argv emulation" is
turned on all the time, regardless of being bundled using py2app?

Any idea of a workaround? This is a program intended to be run both
from the command line and as an app bundle. I tried trimming sys.argv
before importing wx and that doesn't work -- wx seems to grab argv
ahead of time (or gets it straight from the C api).

I did notice that MacOpenFile is deprecated in wxWidgets 3.0 (&
Phoenix?) but MacOpenFiles (plural) doesn't seem to exist yet in
wxPython 2.9.

Thanks,

Rob

Rob McMullen wrote:

I was trying to use MacOpenFile with 2.9.4, and cut the demo out of:

Optimizing for Mac OS X - wxPyWiki

When testing by running from the command line, I get MacOpenFile
called for each of the command line arguments, e.g.:

python MacApp.py test1.txt test2.txt

it gets called for

MacApp.py
test1.txt
test2.txt

which doesn't happen with wx 2.8. Maybe the "argv emulation" is
turned on all the time, regardless of being bundled using py2app?

Hmm... Not sure why that is happening and don't have time to chase it down at the moment.

Any idea of a workaround? This is a program intended to be run both
from the command line and as an app bundle. I tried trimming sys.argv
before importing wx and that doesn't work -- wx seems to grab argv
ahead of time (or gets it straight from the C api).

I did notice that MacOpenFile is deprecated in wxWidgets 3.0 (&
Phoenix?) but MacOpenFiles (plural) doesn't seem to exist yet in
wxPython 2.9.

I've added MacOpenFiles for the next Classic preview build and release, although it's only lightly tested so far. Watch the wxPython-dev list for news about preview build availability.

···

--
Robin Dunn
Software Craftsman