-
Notifications
You must be signed in to change notification settings - Fork 0
/
WebViewQt.py
43 lines (34 loc) · 974 Bytes
/
WebViewQt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/python3
import sys
from PyQt5.QtWebEngineWidgets import QWebEngineView
from PyQt5.QtCore import QEvent, Qt, QUrl, QMargins
from PyQt5.QtWidgets import *
app = QApplication(sys.argv)
class WebView(QWebEngineView):
def __init__(self, parent):
QWebEngineView.__init__(self, parent)
self.load(QUrl("http://www.pracedru.dk:8889"))
class MainWindow(QWidget):
def __init__(self):
QWidget.__init__(self, None)
self.setMinimumHeight(720)
self.setMinimumWidth(360)
self.setMaximumHeight(720)
self.setMaximumWidth(360)
web_view = WebView(self)
layout = QVBoxLayout()
self.setLayout(layout)
layout.setContentsMargins(QMargins(0, 0, 0, 0))
layout.addWidget(web_view)
self.installEventFilter(self)
def eventFilter(self, obj, event):
if event.type() == QEvent.KeyRelease:
if event.key() == Qt.Key_Escape:
print("closing")
self.close()
return True
return False
mw = MainWindow()
# mw.showFullScreen()
mw.show()
app.exec_()