{"id":80704,"date":"2021-05-07T10:43:04","date_gmt":"2021-05-07T05:13:04","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=80704"},"modified":"2026-06-03T15:59:58","modified_gmt":"2026-06-03T10:29:58","slug":"create-web-browser-python-pyqt","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/create-web-browser-python-pyqt\/","title":{"rendered":"How to Create a Web Browser with Python and PyQT"},"content":{"rendered":"<p><strong>Enough of browsing, let&#8217;s create a browser with python<\/strong><\/p>\n<p>In today&#8217;s world, almost everyone is using the internet. To access the world wide web we need a browser.<\/p>\n<p>In this article, we will be creating a simple web browser with python and PyQT5.<\/p>\n<p>PyQT is a widely used module which is used to make GUI applications with much ease. We can develop many complex GUI applications using PyQT very easily. It has a modern look and light user interface. Even if you are not familiar with this module, you will be able to create a web browser as each and every line is explained in the code itself using comments.<\/p>\n<p>We often confused between the terms web browser and search engine, so let\u2019s quickly have a look at these two terms.<\/p>\n<p><strong>Search Engine:<\/strong> It is used to search the required information from the World Wide Web using a web browser. It actually allows us to search the internet.<\/p>\n<p><strong>Web Browser:<\/strong> It is used to access the World Wide Web \/ Internet.<\/p>\n<p>Now, you might have a clear picture of the mentioned terms. We can use any search engine, so we will be using Google search engine in our project.<\/p>\n<h3>Create a Web Browser in Python<\/h3>\n<p><strong>Our python web browser will have the following features:<\/strong><\/p>\n<ul>\n<li>A Previous Button: to navigate to the previously visited site.<\/li>\n<li>A Next Button: to navigate to the next visited site.<\/li>\n<li>A Refresh Button: to reload the current site.<\/li>\n<li>A Search Bar: to load the entered url.<\/li>\n<li>A home button: to navigate back to home.<\/li>\n<\/ul>\n<h3>Prerequisites to create a web browser<\/h3>\n<p>To install the required libraries, please use pip installer from the cmd prompt\/Terminal:<\/p>\n<p><strong>To install pyQT5:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">pip install PyQt5\r\n<\/pre>\n<p><strong>To install pyQtWebEngine<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">pip install PyQtWebEngine\r\n<\/pre>\n<h3>Download python web browser code<\/h3>\n<p>Please download the source code of web browser python project: <a href=\"https:\/\/drive.google.com\/file\/d\/16Y5LKXEuV7v2lEeI-10fIJlgoPVLsuyp\/view?usp=drive_link\"><strong>Web Browser Python Code<\/strong><\/a><\/p>\n<h3>Create Web Browser Python File<\/h3>\n<p><strong>main.py<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import sys\r\n\r\n#importing Widgtes\r\nfrom PyQt5.QtWidgets import *\r\n\r\n#importing Engine Widgets\r\nfrom PyQt5.QtWebEngineWidgets import *\r\n\r\n#importing QtCore to use Qurl\r\nfrom PyQt5.QtCore import *\r\n\r\n#main window class (to create a window)-sub class of QMainWindow class\r\nclass Window(QMainWindow):\r\n\r\n    #defining constructor function\r\n    def __init__(self):\r\n        #creating connnection with parent class constructor\r\n        super(Window,self).__init__()\r\n\r\n        #---------------------adding browser-------------------\r\n        self.browser = QWebEngineView()\r\n\r\n        #setting url for browser, you can use any other url also\r\n        self.browser.setUrl(QUrl('http:\/\/google.com'))\r\n\r\n        #to display google search engine on our browser\r\n        self.setCentralWidget(self.browser)\r\n\r\n        #-------------------full screen mode------------------\r\n        #to display browser in full screen mode, you may comment below line if you don't want to open your browser in full screen mode\r\n        self.showMaximized()\r\n\r\n        #----------------------navbar-------------------------\r\n        #creating a navigation bar for the browser\r\n        navbar = QToolBar()\r\n        #adding created navbar\r\n        self.addToolBar(navbar)\r\n\r\n        #-----------------prev Button-----------------\r\n        #creating prev button\r\n        prevBtn = QAction('Prev',self)\r\n        #when triggered set connection \r\n        prevBtn.triggered.connect(self.browser.back)\r\n        # adding prev button to the navbar\r\n        navbar.addAction(prevBtn)\r\n\r\n        #-----------------next Button---------------\r\n        nextBtn = QAction('Next',self)\r\n        nextBtn.triggered.connect(self.browser.forward)\r\n        navbar.addAction(nextBtn)\r\n\r\n        #-----------refresh Button--------------------\r\n        refreshBtn = QAction('Refresh',self)\r\n        refreshBtn.triggered.connect(self.browser.reload)\r\n        navbar.addAction(refreshBtn)\r\n\r\n        #-----------home button----------------------\r\n        homeBtn = QAction('Home',self)\r\n        #when triggered call home method\r\n        homeBtn.triggered.connect(self.home)\r\n        navbar.addAction(homeBtn)\r\n\r\n        #---------------------search bar---------------------------------\r\n        #to maintain a single line\r\n        self.searchBar = QLineEdit()\r\n        #when someone presses return(enter) call loadUrl method\r\n        self.searchBar.returnPressed.connect(self.loadUrl)\r\n        #adding created seach bar to navbar\r\n        navbar.addWidget(self.searchBar)\r\n\r\n        #if url in the searchBar is changed then call updateUrl method\r\n        self.browser.urlChanged.connect(self.updateUrl)\r\n\r\n    #method to navigate back to home page\r\n    def home(self):\r\n        self.browser.setUrl(QUrl('http:\/\/google.com'))\r\n\r\n    #method to load the required url\r\n    def loadUrl(self):\r\n        #fetching entered url from searchBar\r\n        url = self.searchBar.text()\r\n        #loading url\r\n        self.browser.setUrl(QUrl(url))\r\n\r\n    #method to update the url\r\n    def updateUrl(self, url):\r\n        #changing the content(text) of searchBar\r\n        self.searchBar.setText(url.toString())\r\n\r\n\r\nMyApp = QApplication(sys.argv)\r\n\r\n#setting application name\r\nQApplication.setApplicationName('TechVidvan Web Browser')\r\n\r\n#creating window\r\nwindow = Window()\r\n\r\n#executing created app\r\nMyApp.exec_()\r\n<\/pre>\n<h3>Python Web Browser Output<\/h3>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/05\/python-browser-home.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-80708\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/05\/python-browser-home.png\" alt=\"python browser home\" width=\"1366\" height=\"729\" \/><\/a><\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/05\/browser-load-website.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-80709\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/05\/browser-load-website.png\" alt=\"browser load website\" width=\"1366\" height=\"729\" \/><\/a><\/p>\n<h3>Summary<\/h3>\n<p>We have successfully created a web browser using python and pyqt5. Now you are familiar with another python\u2019s GUI module (apart from tkinter).<\/p>\n<p>We have explained the code using the comments in the code itself but still if you have any doubts. You may ask in the comment section.<\/p>\n<p>Happy Coding !!!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Enough of browsing, let&#8217;s create a browser with python In today&#8217;s world, almost everyone is using the internet. To access the world wide web we need a browser. In this article, we will be&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":80710,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1053],"tags":[3413,3414,483,3415,3249],"class_list":["post-80704","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-create-python-browser","tag-pyqt5-browser","tag-python-project","tag-python-project-code","tag-python-project-for-beginners"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Create a Web Browser with Python and PyQT - TechVidvan<\/title>\n<meta name=\"description\" content=\"Learn how to create a web browser with python and pyqt. In this python project we have used basic concepts of python and pyqt5 for gui\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/create-web-browser-python-pyqt\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Create a Web Browser with Python and PyQT - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"Learn how to create a web browser with python and pyqt. In this python project we have used basic concepts of python and pyqt5 for gui\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/create-web-browser-python-pyqt\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-05-07T05:13:04+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-06-03T10:29:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/05\/create-web-browser-python.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Create a Web Browser with Python and PyQT - TechVidvan","description":"Learn how to create a web browser with python and pyqt. In this python project we have used basic concepts of python and pyqt5 for gui","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/techvidvan.com\/tutorials\/create-web-browser-python-pyqt\/","og_locale":"en_US","og_type":"article","og_title":"How to Create a Web Browser with Python and PyQT - TechVidvan","og_description":"Learn how to create a web browser with python and pyqt. In this python project we have used basic concepts of python and pyqt5 for gui","og_url":"https:\/\/techvidvan.com\/tutorials\/create-web-browser-python-pyqt\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2021-05-07T05:13:04+00:00","article_modified_time":"2026-06-03T10:29:58+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/05\/create-web-browser-python.jpg","type":"image\/jpeg"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/create-web-browser-python-pyqt\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/create-web-browser-python-pyqt\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"How to Create a Web Browser with Python and PyQT","datePublished":"2021-05-07T05:13:04+00:00","dateModified":"2026-06-03T10:29:58+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/create-web-browser-python-pyqt\/"},"wordCount":379,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/create-web-browser-python-pyqt\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/05\/create-web-browser-python.jpg","keywords":["create python browser","pyqt5 browser","Python project","python project code","python project for beginners"],"articleSection":["Python Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/create-web-browser-python-pyqt\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/create-web-browser-python-pyqt\/","url":"https:\/\/techvidvan.com\/tutorials\/create-web-browser-python-pyqt\/","name":"How to Create a Web Browser with Python and PyQT - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/create-web-browser-python-pyqt\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/create-web-browser-python-pyqt\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/05\/create-web-browser-python.jpg","datePublished":"2021-05-07T05:13:04+00:00","dateModified":"2026-06-03T10:29:58+00:00","description":"Learn how to create a web browser with python and pyqt. In this python project we have used basic concepts of python and pyqt5 for gui","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/create-web-browser-python-pyqt\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/create-web-browser-python-pyqt\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/create-web-browser-python-pyqt\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/05\/create-web-browser-python.jpg","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/05\/create-web-browser-python.jpg","width":1200,"height":628},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/create-web-browser-python-pyqt\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"How to Create a Web Browser with Python and PyQT"}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22","name":"TechVidvan Team","description":"The TechVidvan Team delivers practical, beginner-friendly tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our experts are here to help you upskill and excel in today\u2019s tech industry."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/80704","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=80704"}],"version-history":[{"count":2,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/80704\/revisions"}],"predecessor-version":[{"id":448159,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/80704\/revisions\/448159"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/80710"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=80704"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=80704"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=80704"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}