InterviewSolution
| 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 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 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', '') |
|