Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 07-06-2012, 02:35 AM   #46
Agama
Guru
Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.
 
Agama's Avatar
 
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 03:07 AM.
Agama is offline   Reply With Quote
Old 07-07-2012, 08:51 AM   #47
Agama
Guru
Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.
 
Agama's Avatar
 
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.
Agama is offline   Reply With Quote
Advert
Old 07-07-2012, 10:01 AM   #48
kiwidude
calibre/Sigil Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,617
Karma: 2124234
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.
kiwidude is offline   Reply With Quote
Old 07-07-2012, 01:53 PM   #49
Agama
Guru
Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.
 
Agama's Avatar
 
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):
:
and normalise does all the work. So I want get rid of this QDialog but I can't delete the whole class as normalise() is defined within it.
Agama is offline   Reply With Quote
Old 07-07-2012, 02:24 PM   #50
kiwidude
calibre/Sigil Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,617
Karma: 2124234
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():
Or if you still want to have a class, change PlugMain so it doesn't inherit from QDialog:
Code:
    def show_dialog(self):
        plug = PlugMain()
        plug.normalise()

class PlugMain(object):
    def normalise(self):
I'm assuming in the above you don't need any of the gui related parameters, if you do just have a briefer constructor.
kiwidude is offline   Reply With Quote
Advert
Old 07-07-2012, 04:06 PM   #51
Agama
Guru
Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.
 
Agama's Avatar
 
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.
Agama is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

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 02:24 AM
[GUI Plugin] Plugin Updater **Deprecated** kiwidude Plugins 159 06-19-2011 12:27 PM
Help with plugin writing meme Plugins 2 01-21-2011 01:57 PM
Writing an interface action plugin kiwidude Plugins 21 11-11-2010 04:11 PM
New Plugin Type Idea: Library Plugin cgranade Plugins 3 09-15-2010 12:11 PM


All times are GMT -4. The time now is 09:41 AM.


MobileRead.com is a privately owned, operated and funded community.