Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 12-22-2010, 08:27 AM   #1
kiwidude
Calibre Plugins 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,636
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
Can plugins have a custom UI dialog?

I am aware that for custom plugins that the customization_help() function can be used to allow plugins to have a single string value supplied by the user.

However is it at all possible to launch a custom Qt .ui dialog included as part of the plugin zip file? Or are you limited to just the singly .py file containing your plugin code?

I have until now always used "tweaks" for my GUI plugins that require complex configuration. I can appreciate that it would of course be much nicer and consistent with other plugins if such configuration was self-contained and maintained within the plugins dialog instead. However a single "string" isn't a sufficiently powerful function for some of them.

Any other option available or do I just stick to tweaks for now?
kiwidude is offline   Reply With Quote
Old 12-22-2010, 08:31 AM   #2
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,734
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Even if you can't compile the .ui file, you should be able to programmatically build dialog boxes. It isn't hard, even for moderately complex dialogs. For example, the check_library dialog box is built programmatically.

Last edited by chaley; 12-22-2010 at 09:13 AM.
chaley is offline   Reply With Quote
Advert
Old 12-22-2010, 08:48 AM   #3
kiwidude
Calibre Plugins 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,636
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
Quote:
Originally Posted by chaley View Post
Even if you can't compile the .ui file, you should be able to programatically build dialog boxes. It isn't hard, even for moderately complex dialogs. For example, the check_library dialog box is built programatically.
Thanks for the suggestion chaley, I will take a look at that. As I have said before on other threads Python/Qt is new to me but I don't mind dabbling to learn at the moment...
kiwidude is offline   Reply With Quote
Old 12-22-2010, 09:15 AM   #4
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,734
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
One thing you can do is build some UI files, then get python to compile them. Look at the resulting code. You will line after line of widget creation, setup, and adding to the layout. This, plus looking at some of the programmatic dialogs, should help you get started.

Another thing you can do -- use UI files, let python compile them, then capture the resulting _ui.py and put it into your plugin's zip file. No client-side ui compilation would be necessary.
chaley is offline   Reply With Quote
Old 12-22-2010, 09:54 AM   #5
kiwidude
Calibre Plugins 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,636
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
Quote:
Originally Posted by chaley View Post
Another thing you can do -- use UI files, let python compile them, then capture the resulting _ui.py and put it into your plugin's zip file. No client-side ui compilation would be necessary.
Now that sounds pretty good and a nice way to learn the code to generate.

When looking at how I would then actually invoke the dialog (in plugins.py) when the user clicks within the Preferences dialog I found a whole bunch of stuff to do with a "config_widget" function. Presumably this is to support the existing "complex" dialogs like the metadata reader plugins. So looks like there is some kind of infrastructure there that I would need to hook into anyway to allow my custom dialog content to be displayed. I'll do some investigating. Thanks again.

Last edited by kiwidude; 12-22-2010 at 09:56 AM.
kiwidude is offline   Reply With Quote
Advert
Old 12-22-2010, 12:20 PM   #6
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,844
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You can load a .ui file from a plugin zip file and auto compile it, using PyQT4.uic.compileUI (for an example of doing this look at calibre.gui2.build_forms)

And you can have your plugin tell the calibre preferences dialog to use your custom widget by defining two methods on your plugin

Code:
def config_widget(self):
  ...
  return QWidget

def save_setting(self, takes the widget returned previously and stores the settings)
  ...
Look at the MetadataSource class for an example (though I would recommen using JSONConfig rather than XMLConfig ina modern plugin.
kovidgoyal is online now   Reply With Quote
Old 12-22-2010, 12:40 PM   #7
kiwidude
Calibre Plugins 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,636
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
Thanks Kovid for the further info on this. I will keep investigating for some experimenting at some point soon...
kiwidude is offline   Reply With Quote
Old 01-03-2011, 06:42 PM   #8
kiwidude
Calibre Plugins 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,636
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
Quote:
Originally Posted by kovidgoyal View Post
And you can have your plugin tell the calibre preferences dialog to use your custom widget by defining two methods on your plugin

Code:
def config_widget(self):
  ...
  return QWidget

def save_setting(self, takes the widget returned previously and stores the settings)
  ...
Kovid,

I'm rewriting my "Search the internet" plugin to use a custom preferences dialog, so far progressing ok. However can you tell me if there is a way I am missing to persist/restore the size of the plugin configuration dialog itself? I have a grid that could be resized rather wide to show more stuff on screen, but don't want to force it super wide by default.

I figured out all the necessary code to saveGeometry() etc into the JSON file. However of course inside the config_widget() function I have no handle to the config_dialog instance that the widget will be added to. So as far as I can tell, using restoreGeometry() on a widget that does not yet have a parent is effectively useless.

It seems that at best I can set a minimumSize.

Am I missing something? Or will it require a change to Calibre so that instead Calibre takes care of persisting/restoring the size of configuration windows per plugin? (Which would be a better solution anyway so every plugin developer does not have to repeat this code)?

Last edited by kiwidude; 01-03-2011 at 06:44 PM.
kiwidude is offline   Reply With Quote
Old 01-03-2011, 07:04 PM   #9
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,844
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
It will require changes to the calibre code, open a ticket for it so I dont forget.
kovidgoyal is online now   Reply With Quote
Old 01-03-2011, 07:15 PM   #10
kiwidude
Calibre Plugins 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,636
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
Quote:
Originally Posted by kovidgoyal View Post
It will require changes to the calibre code, open a ticket for it so I dont forget.
Cool, thx Kovid, ticket created.
kiwidude is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom GUI plugins for Calibre here... kiwidude Plugins 299 01-27-2011 06:38 PM
New preferences dialog kovidgoyal Calibre 22 09-07-2010 01:04 PM
Dialog Driven Stories MrKyle Writers' Corner 13 08-27-2010 08:37 AM
Cybook Numeric Entry Dialog delphidb96 OpenInkpot 8 08-07-2008 09:54 AM
A dialog with Borders Taylor514ce Sony Reader 45 06-19-2008 11:04 PM


All times are GMT -4. The time now is 07:37 PM.


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