[Tutor] Problem with converting Python to EXE using py2exe
ALAN GAULD
alan.gauld at btinternet.com
Sat Apr 11 09:56:02 CEST 2009
> That's a great idea Mr. Gauld!
> But I have no idea how to do that...
> can you maybe write a small example for a newb like me?? pretty please with cheese on top??
> > > base = pic(file="base.gif")
> > >
> > > Now, I'm just wondering... for the "base.gif" part, would it be better
> > > to write out the whole directory?
>
> > No because that requires that your user install the program and
> > other files exactly where you did. Thats not friendly. Instead use
> > a relative path,
To use a relative path
base = pic(file=root+"/base.gif")
To find out what root is....
> of your project and have a registry setting
Use the _winreg module to access the registry
> or config file or
Use config parser module to read/write to a config file
> environment variable specify where that directory is.
use os.getenv() to read an environment variable
Assuming we go with an environment variable: called MYAPPROOT
root = os.getenv('MYAPPROOT')
base = pic(file=root+"/base.gif")
Now all you need to do is get the installation routine (or the user)
to set up the MYAPPROOT environment variable to point at the
installation directory. How you do that will depend on how you
produce your installer, it could be done by a DOS batch file,
another pytthon script or a commercial installer.
HTH
Alan G.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090411/55d52adf/attachment-0001.htm>
More information about the Tutor
mailing list