[Pythonmac-SIG] Double-clickable wxpython application?
Christopher Barker
Chris.Barker at noaa.gov
Tue Apr 15 07:26:04 CEST 2008
Kevin Horton wrote:
> I have two scripts - the
> program is started by running the GUI script, which calls wx, and
> sets up the whole GUI. This script imports another script, which
> holds all the functions that perform the calculations that are the
> whole purpose of this application. The calculation script reads
> several data files, which live in the same directory as the two
> scripts. I was using relative paths when opening those data files.
> That worked fine if I started the script from the command line. But,
> for a reason that I don't yet understand, when using AppleScript, or
> Automator, I needed to use os.chdir() to point to the correct
> directory before loading the data files.
yes -- where data files lie is always an issue, and , for the most part,
the "current directory" concept really makes no sense with a program
started from the GUI.
For what it's worth, py2app always sets the current dir to some sensible
place. I don't remember where off the top of my head, but it's the same
place that it puts "data files", which makes things like this easy.
> The failure to load the data files did not trigger a traceback, or a
> Console message when the script was started with AppleScript.
Th could be a function of how you initialize your wx.App --
MyApp = wx.App()
defaults to having wx capture the stdout and stderr and try to dump it
to a Window. If your app crashes immediately the errors then get
dropped. Try"
MyApp - wx.App(False)
By the way, I think the default has been changed in the latest version
-- this is the source of a LOT of questions on the wxPython list.
> I had
> to resort to putting write statements in my script to log items of
> interest to a debug file before I could confirm the cause of the
> problem.
wx can also re-direct all output to a file, but I don't remember the
syntax of that one off the top of me head, something like:
wx.App(redirect=filename).
> py2app is not available at the link provided on its download page
Your best bet is to get it with easy-install now:
easy_install py2app
should do it.
http://peak.telecommunity.com/DevCenter/EasyInstall
> I did try py2app from the Fink
> distribution.
I wouldn't expect that to work at all -- they really have one? strange.
-Chris
More information about the Pythonmac-SIG
mailing list