06-13-2013, 02:09 PM | #1 |
Zealot
Posts: 136
Karma: 60
Join Date: Jul 2009
Location: Munich, Germany
Device: Nook Classic rooted; Galaxy S IV with Aldiko, other older devices
|
Long-running tasks and updating dialogs
I am in the process of writing an OPDS Client plugin for Beam Ebooks. The source is at github.
Following the examples in the development manual, I created a dialog (in gui.py), in which I launch my OPDS client. Code:
class DownloadDialog(QDialog): def __init__(self, gui, icon, do_user_config): QDialog.__init__(self, gui) self.gui = gui self.do_user_config = do_user_config ... self.download_button = QPushButton('Download books', self) self.download_button.clicked.connect(self.download) self.layout.addWidget(self.download_button) ... def download(self): # My OPDS stuff is called here... ... |
06-13-2013, 11:00 PM | #2 |
creator of calibre
Posts: 44,561
Karma: 24495948
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
1) Show your dialog with show() not exec_() if you want the dialog to be non-modal
2) Run your download code in a separate thread, but be sure never to interact with the GUI from the separate thread as Qt is not thread safe. 3) Generally, in calibre, long running background tasks are managed witht he jobs system and you only popup a dialog when the task completes to show the results. |
Advert | |
|
06-15-2013, 02:29 AM | #3 |
Zealot
Posts: 136
Karma: 60
Join Date: Jul 2009
Location: Munich, Germany
Device: Nook Classic rooted; Galaxy S IV with Aldiko, other older devices
|
Thank you, I will read through one of the existing plugins to learn how to use the jobs framework.
|
Tags |
opds, pyqt |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Long running series | jbcohen | Reading Recommendations | 49 | 04-14-2013 06:26 PM |
Advisibility of having i62HD's music player running for long periods | Hrafn | Onyx Boox | 0 | 12-30-2012 02:23 AM |
Long words running off page | BKh | ePub | 18 | 08-23-2012 04:47 AM |
Scheduled tasks | Acuum | Kindle Developer's Corner | 4 | 10-03-2010 11:38 PM |
Application pop up dialogs are driving me crazy! | Bob Russell | Lounge | 21 | 05-19-2007 05:22 PM |