Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 06-13-2013, 01:09 PM   #1
hakan42
Zealot
hakan42 is on a distinguished road
 
hakan42's Avatar
 
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...
...
What I am observing is that the GUI of calibre hangs until I return from the download task. Is there something I should do, perhaps somehow periodically yield control back to a GUI thread or something? I must admit that I am not really clueful concerning PyQT
hakan42 is offline   Reply With Quote
Old 06-13-2013, 10:00 PM   #2
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,864
Karma: 22666666
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.
kovidgoyal is offline   Reply With Quote
Old 06-15-2013, 01:29 AM   #3
hakan42
Zealot
hakan42 is on a distinguished road
 
hakan42's Avatar
 
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.
hakan42 is offline   Reply With Quote
Reply

Tags
opds, pyqt


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Long running series jbcohen Reading Recommendations 49 04-14-2013 05:26 PM
Advisibility of having i62HD's music player running for long periods Hrafn Onyx Boox 0 12-30-2012 01:23 AM
Long words running off page BKh ePub 18 08-23-2012 03:47 AM
Scheduled tasks Acuum Kindle Developer's Corner 4 10-03-2010 10:38 PM
Application pop up dialogs are driving me crazy! Bob Russell Lounge 21 05-19-2007 04:22 PM


All times are GMT -4. The time now is 03:36 AM.


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