-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsimpleWebViewer.py
More file actions
42 lines (31 loc) · 894 Bytes
/
simpleWebViewer.py
File metadata and controls
42 lines (31 loc) · 894 Bytes
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
import sys
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtWebEngine import *
from PyQt5.QtWebEngineWidgets import *
from PyQt5.QtWidgets import QApplication, QWidget, QMainWindow
import PyQt5
PyQt5.QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True)
app = QApplication(sys.argv)
class customWebView(QWebEngineView):
def closeEvent(self, event):
# do stuff
if True:
event.accept()
def keyPressEvent(self, e):
if e.key() == Qt.Key_Escape:
sys.exit()
def showUrl(url):
web = customWebView()
web.setWindowState(Qt.WindowMaximized)
web.load(QUrl(url))
web.show()
web.activateWindow()
sys.exit(app.exec_())
url = sys.argv[1]
if not url:
print("Missing url")
else:
showUrl(url)