0

I have what is basically a custom version of PySide for creating plotting applications. The folder structure is as follows:

Juji/
    Images/
    juji/
    Tests/

Where the inner 'juji' folder contains the package. The 'Images' folder contains icons which are used in the package and referenced relatively, e.g:

QtGui.QAction(QtGui.QIcon('Images/chart_edit.png'), 'Plot', self)

When I create an example UI script in the 'Tests' folder and import juji, everything works fine and the icons show.

If I create an external project and try to import 'juji' into it, the GUI shows, but none of the icon pictures show.

I have tried moving the 'Images' folder inside the 'juji' folder, but this doesn't help.

None of the icons are explicitly used outside of the package - surely it should not matter where my external project is relative to it? (I have added it to the PYTHONPATH).

Any ideas?

jramm
  • 6,415
  • 4
  • 34
  • 73
  • possible duplicate of [How load images properly with Python (pyqt)?](http://stackoverflow.com/questions/11842668/how-load-images-properly-with-python-pyqt) – ekhumoro Apr 14 '14 at 17:41

1 Answers1

0

I did a fix which is a bit cludgy:

I moved 'Images' inside juji and created a guidata.py file.

In guidata, I get the absolute path from the __file__ attribute, remove the filename and append the 'Images' folder.

I can then import guidata to each module in the package and use the absolute path to get the icon files. This seems to work with any other external project.

It is a bit of a hack though. A working relative filepath would be much neater, but I just cant seem to get it working.

jramm
  • 6,415
  • 4
  • 34
  • 73