Reputation: 3021
how can I render multiple pages with QtWebkit and process each one with custom python code?
for now I have:
class FetchThumb(object):
def __init__(self):
self.app = QApplication(sys.argv)
self.web = QWebView()
self.app.connect(self.web, SIGNAL("loadFinished(bool)"), self.loadFinished)
def fetch(self, url, options, callback):
self.options = options
self.url = url
self.callback = callback
self.web.load(QUrl(url))
self.app.exec_()
def loadFinished(self, status):
print "URL %s loaded, status is ok? %s" % (self.url, status)
# do something with result...
# exit event loop
self.app.quit()
and I'm calling it once:
fetcher = FetchThumb()
fetcher.fetch(args[-1], options, callback or default_callback)
works. But if I want to use "fetch" again, Qt doesn't respond anymore. What am I missing?
Upvotes: 0
Views: 321
Reputation: 35
In loadFinished
you call self.app.quit()
. This causes the event loop to be stopped whenever the first page finished loading. A workaround would involve not calling self.app.quit()
until you are done with all pages.
Upvotes: 1