-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
57 lines (50 loc) · 2.02 KB
/
main.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import sys
from PyQt5 import QtWidgets, QtCore
from PyQt5.QtWebEngineWidgets import QWebEnginePage, QWebEngineView
from lion import Ui_Form
class mcWidget(QtWidgets.QWidget):
def __init__(self):
super(mcWidget, self).__init__()
def mousePressEvent(self, event):
if event.button() == QtCore.Qt.LeftButton:
self.dragPosition = event.globalPos() - self.frameGeometry().topLeft()
event.accept()
def mouseMoveEvent(self, event):
if event.buttons() == QtCore.Qt.LeftButton:
self.move(event.globalPos() - self.dragPosition)
event.accept()
class browserApp(mcWidget, Ui_Form):
def __init__(self):
super(browserApp, self).__init__()
self.setupUi(self)
self.pushButton.clicked.connect(self.showMinimized)
self.pushButton_2.clicked.connect(sys.exit)
self.pushButton_3.clicked.connect(self.newShowMaximized)
self.lineEdit.returnPressed.connect(self.load)
self.pushButton_4.clicked.connect(self.backward)
self.pushButton_5.clicked.connect(self.forward)
self.pushButton_6.clicked.connect(self.reload)
home = QtCore.QUrl("https://duckduckgo.com")
self.webEngineView.load(home)
def backward(self):
self.webEngineView.page().triggerAction(QWebEnginePage.Back)
def forward(self):
self.webEngineView.page().triggerAction(QWebEnginePage.Forward)
def reload(self):
self.webEngineView.page().triggerAction(QWebEnginePage.Reload)
def load(self):
url = QtCore.QUrl.fromUserInput(self.lineEdit.text())
if url.isValid():
self.webEngineView.load(url)
if self.webEngineView.urlChanged:
self.lineEdit.setText(url.toString())
def newShowMaximized(self):
if self.pushButton_3.isChecked():
self.showMaximized()
else:
self.showNormal()
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
Form = browserApp()
Form.show()
sys.exit(app.exec_())