08-14-2013, 11:20 AM | #1 |
Digital Amanuensis
Posts: 727
Karma: 1446357
Join Date: Dec 2011
Location: Turin, Italy
Device: Several eReaders and tablets
|
Capturing a GUI event
Hi,
is there a way of capturing a GUI event (like "the user clicked on button X" or "the user sent book to device") to trigger the execution of some code (after the "default" action has been completed)? |
08-14-2013, 11:35 AM | #2 |
creator of calibre
Posts: 43,896
Karma: 22666668
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
You can do pretty much anything you want in a plugin. plugin code executes in the same context as normal calibre code, so anything normal code can do, you can do.
If you have some specific event you want to track, ask about it. |
Advert | |
|
08-15-2013, 11:56 AM | #3 |
Digital Amanuensis
Posts: 727
Karma: 1446357
Join Date: Dec 2011
Location: Turin, Italy
Device: Several eReaders and tablets
|
Thanks for the quick reply.
I would like to modify a custom metadatum field for a library entry whenever I "send to device" it. So far, I understand that I can achieve that by writing a device plugin, but I have multiple eReaders and I do not want to write a plugin for each of them. Hence, my original request. I am still confused on how can I capture the "send to device" event, in order to trigger the execution of my own code. I looked at the plugins in the official index, but I was not able to identify one which might do something similar to what I need. Would you mind suggesting one, please? |
08-15-2013, 12:29 PM | #4 |
creator of calibre
Posts: 43,896
Karma: 22666668
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
I doubt there's any existing plugin that does that. You will basically need to hook into the books_uploaded function defined in gui2/device.py
The easiest way is to simply replace that function with your own, something like self.original_books_uploaded = self.gui.books_uploaded self.gui.books_upload = self.my_books_uploaded def my_books_uploaded(self, job): self.original_books_uploaded(job) # do whatever you want to do There maybe some function binding issues you will have to deal with, basically ensure that self is the right object in every context. A bit of googling about python monkey patching should tell you how. |
08-15-2013, 12:37 PM | #5 |
Digital Amanuensis
Posts: 727
Karma: 1446357
Join Date: Dec 2011
Location: Turin, Italy
Device: Several eReaders and tablets
|
Got it, thanks.
|
Advert | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Capturing screen shot from NC | Rebo | Nook Color & Nook Tablet | 3 | 11-26-2010 03:06 PM |
capturing text overlaid/within non-rectangular images | CharlesinCharge | ePub | 2 | 10-27-2010 04:53 AM |
Regex capturing variables | Lonas | Sigil | 9 | 08-14-2010 03:05 PM |
700 or K2 for highlighting, capturing & take notes + whole family | Douglasco | Which one should I buy? | 7 | 02-25-2009 08:46 AM |
Entertaining, capturing and inspiring soul teaser | irapas1 | Reading Recommendations | 0 | 10-25-2003 07:15 AM |