Hey guys! in this post I will show you that how you can create your own browser in Python!! With just 65 lines of python code. I will also show you that how to convert it into a .EXE file later... So let's see how to create it without any furder delay!
Here is the video of it You can watch it! So let's move on to the explanation and the code!
Process:-
Frist open VS Code or PyCharm then create a main.py file the comes back to this post, go below and copy the code and paste and save the file. Then just run the file. Please Install the PyQt5 module!!!
Modules needed!:-
pip install PyQt5
Code:-
import sysfrom PyQt5.QtCore import *from PyQt5.QtWidgets import *from PyQt5.QtWebEngineWidgets import*class MainWindow(QMainWindow):def __init__(self):super(MainWindow, self).__init__()self.browser = QWebEngineView()self.browser.setUrl(QUrl('http://google.com'))self.setCentralWidget(self.browser)self.showMaximized()#navbarnavbar = QToolBar()self.addToolBar(navbar)back_btn = QAction('Back', self)back_btn.triggered.connect(self.browser.back)navbar.addAction(back_btn)forward_btn = QAction('Forward', self)forward_btn.triggered.connect(self.browser.forward)navbar.addAction(forward_btn)reload_btn = QAction('Reload', self)reload_btn.triggered.connect(self.browser.reload)navbar.addAction(reload_btn)home_btn = QAction('Home', self)home_btn.triggered.connect(self.home)navbar.addAction(home_btn)self.url_bar = QLineEdit()self.url_bar.returnPressed.connect(self.Url)navbar.addWidget(self.url_bar)self.browser.urlChanged.connect(self.Update_url)def Url(self):url = self.url_bar.text()self.browser.setUrl(QUrl(url))def Update_url(self, q):self.url_bar.setText(q.toString())def home(self):self.browser.setUrl(QUrl('http://google.com'))app = QApplication(sys.argv)QApplication.setWindowIcon('')QApplication.setApplicationName('Chrome browser | By:- Abhinav Mishra')window = MainWindow()app.exec_()
Hope you guys like this post if yes then please please li and Subscribe to my channel!! See you in the new post! Bye!
GoodBye!
2 Comments
Hello, how can i make Customizations?
ReplyDeleteLike Google Chrome has Print, More Tools, Incognito and all.
Yaa sure! But it will be tooo advanced! By the way great idea! I will try to make it. Actually the problem is that I am new to Python! But I will try! Please Subscribe my YouTube Channel to get update wen ever I upload a video!
Delete