06-30-2012, 05:13 PM | #31 |
Guru
Posts: 776
Karma: 2751519
Join Date: Jul 2010
Location: UK
Device: PW2, Nexus7
|
Perfect! Thank-you.
It's taking a bit of time to get to grips with Python but I'm really starting to enjoy it! (I've been a UniBasic analyst/programmer for 15 years, with previous experience in Fortran 77 and x86 assembler and these are nothing like Python with all its classes/methods etc., so this might account for some of my questions being a bit simple.) Last edited by Agama; 06-30-2012 at 05:22 PM. |
06-30-2012, 05:30 PM | #32 |
Calibre Plugins Developer
Posts: 4,637
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
What IDE are you using? You should be able to setup the python path for your project workspace if you are using Eclipse or Aptana so that hovering over such imports will give you big handy tootltips and allow you to navigate straight to the source files. Invaluable for navigating the code, be it calibre code or python imports.
|
Advert | |
|
06-30-2012, 05:35 PM | #33 |
Guru
Posts: 776
Karma: 2751519
Join Date: Jul 2010
Location: UK
Device: PW2, Nexus7
|
IDE?? I'm just using Notepad++
Python appears to have installed something called IDLE (Python GUI) on my Windows start menu. Would this be an IDE? P.S. I ran IDLE and the Help > About says that it's "Python's Integrated DeveLopment Environment" so this sounds quite likely. Last edited by Agama; 06-30-2012 at 06:08 PM. |
06-30-2012, 10:35 PM | #34 |
creator of calibre
Posts: 43,857
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
I dont think IDLE has the "go to definition" functionality that kiwidude is talking about. You need to use something like Eclipse+PyDev or ViM with an appropriately created tags file for that. In general anything that comes from calibre's code will have its import of the form
from calibre.... anything else comes from either the python stdlib or a python third party package. |
07-01-2012, 12:29 PM | #35 |
Guru
Posts: 776
Karma: 2751519
Join Date: Jul 2010
Location: UK
Device: PW2, Nexus7
|
I checked: there's no "go to definition" in IDLE.
Is there anyway to add the "Load plug-in from file" command to the main toolbar? I couldn't find it in the list of available actions and I use this command a lot whilst testing my plugins. Now I guess I could write a plugin just to add this function to the toolbar, but that seems a bit over the top. |
Advert | |
|
07-01-2012, 12:33 PM | #36 |
Calibre Plugins Developer
Posts: 4,637
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
Do it from the command line with a script - I always have a batch file with rebuilds the zip, installs it and then launches calibre for testing.
This is to install it: calibre-customize -a "%ZIPNAME%.zip" |
07-02-2012, 12:36 AM | #37 |
creator of calibre
Posts: 43,857
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
You dont need a script, read the last couple of paragraphs here: http://manual.calibre-ebook.com/crea...ugging-plugins
|
07-02-2012, 07:35 AM | #38 |
Guru
Posts: 776
Karma: 2751519
Join Date: Jul 2010
Location: UK
Device: PW2, Nexus7
|
Thanks. calibre -s; zip -r /path/to/plugin/zip/file.zip *; calibre is much better than my rather manual method.
I went looking for a zip utililty with a command line to use with this script and found 7-Zip for Windows to be very useful. A couple of features in particular help in this context: 1) 7-Zip can be made the default program to open .zip files. 2) 7-Zip allows files within the zip to be edited directly, unlike the Windows built-in option. Last edited by Agama; 07-02-2012 at 02:13 PM. |
07-04-2012, 04:57 PM | #39 |
Guru
Posts: 776
Karma: 2751519
Join Date: Jul 2010
Location: UK
Device: PW2, Nexus7
|
How can I change the width of the QDialog box that my plugin uses?
Based on the interface_demo plugin my box uses self.resize(self.sizeHint()) - but because my buttons have short names the text in the title bar of the dialog gets cropped. So, can I make the dialog wider? |
07-04-2012, 05:35 PM | #40 |
Calibre Plugins Developer
Posts: 4,637
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
QDialog has a setMinimumWidth() function you can use.
|
07-05-2012, 07:25 AM | #41 |
Guru
Posts: 776
Karma: 2751519
Join Date: Jul 2010
Location: UK
Device: PW2, Nexus7
|
Thanks. I used your reply to find the Qt documentation at http://qt-project.org/doc/, so I'll check any further Qt issues there first of all. Which version of Qt does calibre use?
I want to test some of the standard Python os and io functions to understand their use before incorporating into my plugin. Is there any way to play with them outside of a plugin? |
07-05-2012, 07:35 AM | #42 | ||
Calibre Plugins Developer
Posts: 4,637
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
Quote:
Quote:
Or you can create a __main__ section in the bottom of one of your plugin files for testing, you will see that around the place in calibre code and the odd plugin. |
||
07-05-2012, 01:48 PM | #43 |
Grand Sorcerer
Posts: 12,166
Karma: 73448616
Join Date: Nov 2007
Location: Toronto
Device: Nexus 7, Clara, Touch, Tolino EPOS
|
Couldn't you also just run either python with no command line options and type commands in, or run idle and use the python supplied IDE ?
|
07-05-2012, 02:23 PM | #44 |
Calibre Plugins Developer
Posts: 4,637
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
Sure you "could" - but it means yet another way of doing things that won't work when suddenly your test code needs a library or function that is in calibre. Which happens *alot* for me at least. So rather than have to deal with two different ways of doing things just because a line or two of your test code has changed I gave Agama the simplest answer which has worked for me.
I just keep a command line window open to run calibre-debug -e with (a simple up-arrow enter to re-run things), and edit the test file within Eclipse along with the plugin code. You still get all the code analysis checking of the IDE, but can run *any* code be it 100% python only or a mixture using the same approach. |
07-06-2012, 01:18 AM | #45 |
creator of calibre
Posts: 43,857
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Note that running calibre-debug with no arguments gives you a python prompt where you can run arbitrary commands, including importing stuff from calibre.
|
|
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 |