Ahh. I know. Long day.
···
On 8/14/07, Brian Martin thebrianmartin@gmail.com wrote:
Thanks for the typical mailing list punch-in-the-face.
On 8/14/07, Chris Mellon < > arkanes@gmail.com> wrote:
On 8/14/07, Brian Martin < > > thebrianmartin@gmail.com > > > wrote:
Just some weird things that happened during my project that I wanted to
share…
- For simplicity sake (and because my installer knowledge was minimal),
I was just putting icons and logos for my application in the root directoryof 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’) andwxpython (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. Assoon 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.
- 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 nosearching for the icons and images here: “C:\Program
Files\proj\library.zip\hello
.gif” where sys.path[0] contained: C:\Program
Files\proj\library.zipsys.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.
- 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@lists.wxwidgets.org
For additional commands, e-mail:
wxPython-users-help@lists.wxwidgets.org