-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbrowser.py
69 lines (51 loc) · 2.14 KB
/
browser.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
58
59
60
61
62
63
64
65
66
67
68
69
import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtWebEngineWidgets import *
class Browser(QMainWindow):
def __init__(self):
super(Browser,self).__init__()
self.browser=QWebEngineView()
self.browser.setUrl(QUrl("http://www.google.co.in/"))
self.setCentralWidget(self.browser)
self.showMaximized()
# Creating a Navigation Bar or Navbar
self.navbar=QToolBar()
self.addToolBar(self.navbar)
# Adding buttons to the Navigation Bar
self.backbutton=QAction('Back',parent=self)
self.backbutton.setIcon(QIcon('Back.png'))
self.backbutton.triggered.connect(self.browser.back)
self.navbar.addAction(self.backbutton)
self.forwardbutton=QAction('Forward',parent=self)
self.forwardbutton.setIcon(QIcon('Forward.png'))
self.forwardbutton.triggered.connect(self.browser.forward)
self.navbar.addAction(self.forwardbutton)
self.reloadbutton=QAction('Reload',parent=self)
self.reloadbutton.setIcon(QIcon('Reload.png'))
self.reloadbutton.triggered.connect(self.browser.reload)
self.navbar.addAction(self.reloadbutton)
# Adding Search Bar to the Navigation Bar
self.search_bar=QLineEdit()
self.search_bar.returnPressed.connect(self.goto_url)
self.navbar.addWidget(self.search_bar)
self.browser.urlChanged.connect(self.updateurl)
# Adding Home Button to the Navigation Bar
self.homebutton=QAction('Home',parent=self)
self.homebutton.setIcon(QIcon('Home.png'))
self.homebutton.triggered.connect(self.goto_home)
self.navbar.addAction(self.homebutton)
def goto_home(self):
self.browser.setUrl(QUrl("http://www.google.co.in/"))
def goto_url(self):
url=self.search_bar.text()
self.browser.setUrl(QUrl(url))
def updateurl(self,url):
self.search_bar.setText(url.toString())
if __name__=="__main__":
app=QApplication(sys.argv)
app.setApplicationName('J.E.N Browser')
app.setWindowIcon(QIcon('JEN.png'))
window=Browser()
app.exec_()