Randint
Randint

Reputation: 73

How to make an Web Browser with Python 3.8

I trying to find out how to make an Web Browser using Python 3.8, but nothing works. Most of the tutorials or articles I find just opens links in Firefox (I use Firefox) using the webbrowser module. The rest of them use PyQt, which for some reason just doesn't work on my computer (I'm using Windows 10). When I import PyQt from PyQt5.QtGui import QApplication it says ModuleNotFoundError: No module named 'PyQt5.QtGui'. I'm trying to make it simple, just an search bar for getting the urls and a place to display the webpage. Maybe something like this:

Image Mozarella Ashbadger browser made with PyQT

Upvotes: 1

Views: 2934

Answers (1)

Further Reading
Further Reading

Reputation: 253

PyQt5 went through some changes in the last few years which might be causing your issues.

I have tested the following method recently as part of a package I recently made with a integrated webbrowser, so as of writing (October 2020) it will work.

First you need to also install an additional module PyQtWebEngine. then the following code should open a single page.

import sys
from PyQt5.QtCore import *
from PyQt5.QtWebEngineWidgets import *
from PyQt5.QtWidgets import QApplication
 
app = QApplication(sys.argv)
 
web = QWebEngineView()
web.load(QUrl("https://stackoverflow.com/"))
web.show()
 
sys.exit(app.exec_())

Anything more than that will require some UI work, but it should be easier now that you have the web part of it handled.

Upvotes: 1

Related Questions