GUI icons in snap

My python app uses custom icons, what are on separate folder: icons/
In python script: self.setWindowIcon(QtGui.QIcon('icons/tauno-plotter.svg'))
And everything works when I run manually python script. But I have not figured out how to use them inside snap?
I can copy them somewhere, but my script can’t see them.
plugin: dump
source: ./tauno-serial-plotter/icons/
‘*.svg’ : bin/icons/
- bin/icons/

If you’re using a relative path like that, it will look things up relative to the current working directory. That might work when running your app from the source directory, but is likely to fail if you’ve installed the app (whether via a snap or directly via setuptools, or whatever).

If you want to locate the file relative to the location of the Python script, one common approach is to use the __file__ special variable which is set to the path of module. So you might do something like:

filename = os.path.join(os.path.dirname(__file__), 'icons/tauno-plotter.svg')
1 Like

Yes, it works now. Thank You very much!