Created
February 5, 2017 10:05
-
-
Save nudomarinero/65182def0192996f85b0aebc467ffaaf to your computer and use it in GitHub Desktop.
Qt5 Web test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
import PyQt5 | |
from PyQt5.QtWidgets import QApplication | |
from PyQt5.QtCore import QThread, QUrl | |
from PyQt5.QtWebKitWidgets import QWebView | |
from bottle import Bottle | |
class ControllerThread(QThread): | |
def __init__(self, application): | |
QThread.__init__(self) | |
self.application = application | |
def __del__(self): | |
self.wait() | |
def run(self): | |
self.application.run(host='localhost', port=8085) | |
webapp = Bottle() | |
@webapp.route('/') | |
def index(): | |
return "Hola mundo" | |
#if __name__ == "__main__": | |
# Create the application object | |
app = QApplication(sys.argv) | |
# Bottle application | |
bottleapp = ControllerThread(webapp) | |
bottleapp.start() | |
app.aboutToQuit.connect(bottleapp.terminate) | |
view = QWebView() | |
view.load(QUrl('http://localhost:8085/')) | |
view.show() | |
sys.exit(app.exec_()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment