I found load_resources in InterfaceAction helpful:
https://github.com/kovidgoyal/calibr...init__.py#L260
Code:
If this plugin comes in a ZIP file (user added plugin), this method
will allow you to load resources from the ZIP file.
For example to load an image::
pixmap = QPixmap()
pixmap.loadFromData(self.load_resources(['images/icon.png']).itervalues().next())
icon = QIcon(pixmap)
:param names: List of paths to resources in the zip file using / as separator
:return: A dictionary of the form ``{name : file_contents}``. Any names
that were not found in the zip file will not be present in the
dictionary.
Here is how I used it for Kaliweb plugin:
https://bitbucket.org/kabiir/kaliweb...t=master#cl-65
In short, in InterfaceAction.genesis:
Code:
res = self.load_resources(PORTABLE_RESOURCES)
for resource in res.keys():
res[resource] #get data
I unpack resources from .zip file to temporary directory so that can be used during the running session. Then I use 'close' hook to delete that temporary directory