![]() |
Using image in plugin code
In the Prince PDF plugin I use two small images in the "about" dialog (second screnshot in that thread). However, I just noticed it doesn't work. In fact, the images are not read from the plugin file, but from the current directory, so I only see the images if I launch calibre from the directory where I'm developing the plugin (that's why I thought it worked before).
What I want is using the images in HTML code, which currently looks something like this: Code:
<p style="margin:1em 0 0 0"><img src=":images/prince_icon.png"/> <i>Prince is copyrighted © YesLogic Pty. Ltd.</i></p> |
In what context are you using this HTML file? Just extract the images into a temp directory and use absolute paths to them, that way it will always work.
|
It's just the text for the "about" or "help" dialog (inside the plugin). I simply define a variable with the HTML code:
Code:
help_txt = _('''Code:
QMessageBox.about(self, _('About the Prince PDF Plugin'), help_txt) |
Code:
from calibre.ptempfile import TemporaryDirectory |
Quote:
Code:
with open(os.path.join(tdir, x),'w') as f:A minor, probably trivial question: How can I access the "version" defined in __init__ (or "name", or "author"...) from elsewhere inside the plugin code? |
from calibre_plugins.<plugin_name> import version
|
That works for __copyright__, which is defined outside the class, but not for version, which is inside:
Code:
from __future__ import (unicode_literals, division, absolute_import, print_function)I must be doing something wrong. |
So either define version outside the class like this
version = xxx class MyClass: version = version or import the class from calibre_plugins.plugin_name import MyClass version = MyClass.version |
| All times are GMT -4. The time now is 08:29 PM. |
Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.