![]() |
#1 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,507
Karma: 204127028
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
plugin_path for editor plugins.
Is there (or can there be) an easy method to obtain the path to the plugin's own zip file (like self.plugin_path in the run method of a File type plugin) in an editor plugin's main.py:Tool classes? For the purpose of extracting resources. The os.path.join(config_dir, 'plugins', '{}.zip'.format(plugin_name)) method seems a little fragile.
|
![]() |
![]() |
![]() |
#2 |
Member
![]() Posts: 15
Karma: 10
Join Date: Feb 2014
Device: none
|
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. 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 ![]() |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,252
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
|
![]() |
![]() |
![]() |
#4 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,507
Karma: 204127028
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Thanks guys. I don't know why I was making that more difficult than it was.
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Editor: ToC Editor: Start entry | macnab69 | Editor | 2 | 06-25-2014 11:15 AM |
Book Editor TOC Editor Isue? | weberr | Editor | 2 | 04-17-2014 11:13 AM |
Plugins | junkml | Plugins | 32 | 06-19-2009 06:43 AM |
Plugins? | Mitchll | Plugins | 0 | 12-27-2008 02:36 PM |