Total Newb question on icons

Working through some tutorials i keep seeing and writing code like:

  toolbar1.AddLabelTool(wx.ID_ANY, '', wx.Bitmap('icons/new.png'))

where are these icons supposed to be located? Just to make some of the sample code work I copied the icon directory from the wx.demo and put it into my coding directory, it will pick up the icons from there, but there are others in the code that are not in this limited sample.

is there a "conventional" place where these icons reside? is it system specific? I tried googling, but I'm not phrasing my question properly or something. sorry for the rank newbieness of this question.

This is less a Python thing than an operating systems thing… in general, writing “icons/new.png” means “look in the current directory for a subdirectory called icons, and for a file called new.png in that subdirectory.” This is called a “relative path”, because the actual location of the file is defined as being relative to the current working directory. All well and good - but what’s the current directory? It could be where you were when you first invoked the Python interpreter; it could be the folder that Python itself is in, or some subfolder; if you invoked your script from a desktop shortcut, it could be the Desktop folder… the list goes on.

All of which is to say: don’t make any assumptions. You can either set the current working directory explicitly, and then use relative paths, or you can use absolute paths if you know that the files you need are always going to be in the same place. (An absolute path is one that specifies the destination without needing any context, e.g. “C:\Python27\Lib\site-packages\wx-2.8-msw-unicode\wx\tools\Editra\pixmaps\theme\Tango\menu\computer.png”.)

As for whether there’s any conventional location… no, not that I’m aware of.

···

On Wed, Sep 7, 2011 at 11:05 AM, David Webb cadizgramps@gmail.com wrote:

Working through some tutorials i keep seeing and writing code like:

toolbar1.AddLabelTool(wx.ID_ANY, ‘’, wx.Bitmap(‘icons/new.png’))

where are these icons supposed to be located? Just to make some of the sample code work I copied the icon directory from the wx.demo and put it into my coding directory, it will pick up the icons from there, but there are others in the code that are not in this limited sample.

is there a “conventional” place where these icons reside? is it system specific? I tried googling, but I’m not phrasing my question properly or something. sorry for the rank newbieness of this question.

Well, the “conventional” location for an application’s resources varies from app to app. Most developers store this sort of thing in the application’s main installation folder. Others might put it in the Application Data folder. It’s really up to you where you store your icons.

···

Mike Driscoll

Blog: http://blog.pythonlibrary.org

And from platform to platform. If you want to conform to platform standards then you can use wxStandardPaths to help you know where to put and to find different types of files that belong to your application. For icons and such you also have the ability to embed them in Python code using the img2py tool.

···

On 9/8/11 11:04 AM, Mike Driscoll wrote:

Well, the "conventional" location for an application's resources varies
from app to app.

--
Robin Dunn
Software Craftsman