1.

Why Do The Paths To My Resource Files Work In Testing, But Fail After Installation On Windows?

Answer»

This is a known problem. In testing, the relative paths POINT to the files correctly, but after installation the relative paths do not point to the intended LOCATION. To remedy this, you will need to provide a dynamic absolute path to the resource files.

Insert the following code in your main Python FILE:

import sys
import os.path
import __builtin__
# Sets the homepath variable (you can change the name) to the directory where your application is located (sys.argv[0]).
__builtin__.__dict__['homepath'] = os.path.abspath(os.path.dirname(sys.argv[0]))

Whenever you need to load a resource file, you have to append homepath as FOLLOWS, using os.path.join(). Your application will now load directory names correctly in both testing and post-installation.

toolbar.AddSimpleTool(1, wx.Image(os.path.join(homepath, 'resfilenew.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'New', '')

This is a known problem. In testing, the relative paths point to the files correctly, but after installation the relative paths do not point to the intended location. To remedy this, you will need to provide a dynamic absolute path to the resource files.

Insert the following code in your main Python file:

import sys
import os.path
import __builtin__
# Sets the homepath variable (you can change the name) to the directory where your application is located (sys.argv[0]).
__builtin__.__dict__['homepath'] = os.path.abspath(os.path.dirname(sys.argv[0]))

Whenever you need to load a resource file, you have to append homepath as follows, using os.path.join(). Your application will now load directory names correctly in both testing and post-installation.

toolbar.AddSimpleTool(1, wx.Image(os.path.join(homepath, 'resfilenew.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'New', '')



Discussion

No Comment Found