Reputation: 35099
I want to close the window after loadFinished complete. imagine simple code:
class Example(QWebView):
def __init__(self):
QWebView.__init__(self)
self.frame = self.page().mainFrame()
self.frame.loadFinished.connect(self.some_action)
def some_action(self):
# do something here
# after it's done close app
if __name__ == '__main__':
app = QApplication(sys.argv)
url = QUrl("some_website")
br = Example()
br.load(url)
br.show()
app.exec_()
Upvotes: 0
Views: 306
Reputation: 120578
Just call close() on the main window:
def some_action(self):
# do something here
# after it's done close app
self.close()
Once the last primary window is closed, the application will automatically quit.
You could also just call the application's quit function directly:
app.quit()
or, more generally:
QCoreApplication.instance().quit()
Upvotes: 1