[wxPython-users] a couple of scary moments in wxpython under
win32 under py2exe with a ridiculous deadline thrown in...
Brian Martin
thebrianmartin at gmail.com
Tue Aug 14 20:23:38 PDT 2007
Ahh. I know. Long day.
On 8/14/07, Brian Martin <thebrianmartin at gmail.com> wrote:
>
> Thanks for the typical mailing list punch-in-the-face.
>
> On 8/14/07, Chris Mellon <arkanes at gmail.com> wrote:
> >
> > On 8/14/07, Brian Martin <thebrianmartin at gmail.com > wrote:
> > > Just some weird things that happened during my project that I wanted
> > to
> > > share....
> > >
> > > 1) For simplicity sake (and because my installer knowledge was
> > minimal),
> > > I was just putting icons and logos for my application in the root
> > directory
> > > of the source folder. When I would refer
> > > to them when creating an image for example i could just exclude any
> > path
> > > information (ie. 'foo.img' vs 'c:\Program Files\proj\foo.img') and
> > > wxpython (or python) would know how to get them. Then, when adding a
> > feature
> > > to allow someone to add a custom graphic to the application I make a
> > call to
> > > shutil.copy to move the image from a user location into the source
> > tree. As
> > > soon as I do this, wxpython could not find any of my images or icons.
> > I had
> > > to explicitly point to them or it would barf. Now this is probably the
> > best
> > > way to do it and I just made a global constant which used sys.path[0].
> > > Regardless, it was interesting. Mid-application, references to these
> > images
> > > were broken when i called the shutil.copy command.
> > >
> >
> > Your problem here is lack of knowledge. All common OSes have a concept
> > known as the "current working directory". Relative paths are so called
> > because they are relative to this directory.
> >
> > You probably used wx.FileDialog to allow the user to select the file
> > to move. wx.FileDialog changes the current working directory, because
> > windows is bizarre. Clear the wx.FD_CHANGE_DIR style flag to prevent
> > this behavior.
> >
> > There's actually lots of different ways this can fail and you've run
> > into only one of them. Because of this, relying on the current working
> > directory to find your data files is heavily discouraged.
> >
> > > 2) This is related to #1 and was extremely stressful at the time. I
> > packaged
> > > this project up for my boss to take to a presentation using py2exe.
> > The
> > > killer here is that *while running under py2exe* the sys.path contains
> > a
> > > single entry which is the "library.zip" file. So my application was no
> >
> > > searching for the icons and images here: "C:\Program
> > > Files\proj\library.zip\hello
> > > .gif" where sys.path[0] contained: C:\Program
> > > Files\proj\library.zip
> > >
> >
> > sys.path isn't intended to be used to find your data files. It's a
> > mechanism used by Python to find imports. wxPython, in the interests
> > of platform compatability, provides the wx.StandardPaths class which
> > can help you find well-defined file locations.
> >
> > > 3) Keyboard events between win32 and Linux are a not compatible. You
> > cannot
> > > depend on it working remotely the same if you, for example, spend part
> > of an
> > > evening in Ubuntu working on a project and then try it on XP the next
> > > morning at work.
> >
> > You should always test on platforms that you are going to deploy on.
> > There are some platform differences but by far a larger category of
> > problems is incorrect code that happens to work on one platform
> > failing on another. Giving details about your problem will help more
> > than broad statements of incompatibility.
>
>
>
>
>
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: wxPython-users-unsubscribe at lists.wxwidgets.org
> > For additional commands, e-mail: wxPython-users-help at lists.wxwidgets.org
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200708=
14/f37c6cc9/attachment.htm
More information about the wxpython-users
mailing list