|
|
#46 |
|
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 776
Karma: 2751519
Join Date: Jul 2010
Location: UK
Device: PW2, Nexus7
|
I hadn't even got as far as considering that calibre functions might not be available - I had fallen at the first hurdle! I didn't know how to use .py files outside of calibre. I had a look at IDLE, which Python had installed, but it seemed to be just a command prompt rather than a place for running .py files.
Last edited by Agama; 07-06-2012 at 04:07 AM. |
|
|
|
|
|
#47 |
|
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 776
Karma: 2751519
Join Date: Jul 2010
Location: UK
Device: PW2, Nexus7
|
I've got my plugin well on the way to working as required, so I would now like to remove the QDialog in main.py which is called from ui.py, (as per the interface demo plugin), and just let the plugin run when its tool button is clicked on the main toolbar. I've got the icon on the toolbar but I don't know what to replace the QDialog with. I still need main.py as it contains all my code; I just don't need the dialog.
|
|
|
|
| Advert | |
|
|
|
|
#48 |
|
Calibre Plugins Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,735
Karma: 2208556
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
What is the name of your function in main.py that does the work?
At the moment presumably you are still hooking to a show_dialog function of the qaction triggered event with this line: self.qaction.triggered.connect(self.show_dialog) So other than renaming your show_dialog function to something more meaningful (e.g. do_stuff), you should just change your do_stuff function to now call whatever your function name is in main.py that you have imported. It is kind of hard to be more specific without seeing your code - you can always pm me a link or post it here if you want us to take a look. |
|
|
|
|
|
#49 |
|
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 776
Karma: 2751519
Join Date: Jul 2010
Location: UK
Device: PW2, Nexus7
|
Some code snippets should make things clearer.
(Colon's show where some lines of code have been skipped.) Code:
ui.py has
from calibre_plugins.ag_normepub.main import PlugMain
:
self.qaction.triggered.connect(self.show_dialog)
:
def show_dialog(self):
:
ufig = self.interface_action_base_plugin.do_user_config
plug = PlugMain(self.gui, self.qaction.icon(), ufig)
plug.show()
main.py has:
class PlugMain(QDialog):
def __init__(self, gui, icon, ufig):
self.gui = gui
self.ufig = ufig
QDialog.__init__(self, gui)
:
self.btn_norm = QPushButton('Normalise ePub', self)
self.btn_norm.clicked.connect(self.normalise)
self.lay.addWidget(self.btn_norm)
:
def normalise(self):
:
|
|
|
|
|
|
#50 |
|
Calibre Plugins Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,735
Karma: 2208556
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
Well you've got a few choices. You don't "have" to have a class, you can just declare normalise at the module level (reduce the indentation) and then change your show_dialog so it just says:
Code:
def show_dialog(self):
from calibre_plugins.ag_normepub.main import normalise
normalise()
def normalise():
Code:
def show_dialog(self):
plug = PlugMain()
plug.normalise()
class PlugMain(object):
def normalise(self):
|
|
|
|
| Advert | |
|
|
|
|
#51 |
|
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 776
Karma: 2751519
Join Date: Jul 2010
Location: UK
Device: PW2, Nexus7
|
The first option looks ideal. I didn't realise that I could have a def outside of a class.
|
|
|
|
![]() |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Plugin not customizable: Plugin: HTML Output does not need customization | flyingfoxlee | Conversion | 2 | 02-24-2012 03:24 AM |
| [GUI Plugin] Plugin Updater **Deprecated** | kiwidude | Plugins | 159 | 06-19-2011 01:27 PM |
| Help with plugin writing | meme | Plugins | 2 | 01-21-2011 02:57 PM |
| Writing an interface action plugin | kiwidude | Plugins | 21 | 11-11-2010 05:11 PM |
| New Plugin Type Idea: Library Plugin | cgranade | Plugins | 3 | 09-15-2010 01:11 PM |