How to make my own web Browser

Make your own Web Browser in Python using PyQt5. PyQt5 is a very powerful Python framework to make modern GUIs. With help of Python PyQt5 QtWebWidgets, it is very easy to amke your own custom web browser with a few lines of code.

PyQt5 Basic code


import sys
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *

class MainWindow(QMainWindow):
    def __init__(self):
        # Main Window
        super(MainWindow, self).__init__()
        self.showMaximized()

app = QApplication(sys.argv)
QApplication.setApplicationName("Browser")
window = MainWindow()
app.exec_()



PyQt5 Browser code using QtWebEngine


import sys
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtWebEngineWidgets import *

class MainWindow(QMainWindow):
    def __init__(self):
        # Main Window
        super(MainWindow, self).__init__()
        self.browser = QWebEngineView()
        self.browser.setUrl(QUrl('https://google.com'))
        self.setCentralWidget(self.browser)
        self.showMaximized()

        # nav bar
        navBar = QToolBar()
        self.addToolBar(navBar)

        backBtn = QAction("Back", self)     # back Button
        backBtn.triggered.connect(self.browser.back)
        navBar.addAction(backBtn)

        forwardBtn = QAction("Forward", self)   # forward Button
        forwardBtn.triggered.connect(self.browser.forward)
        navBar.addAction(forwardBtn)

        relBtn = QAction("Reload", self)    # Reload Button
        relBtn.triggered.connect(self.browser.reload)
        navBar.addAction(relBtn)

app = QApplication(sys.argv)
QApplication.setApplicationName("Browser")
window = MainWindow()
app.exec_()



The final look of the browser after the above code.
Make your own Web Browser in Python - Python PyQt5 tutorial - QtWebEngineWidgets


So, I think that's it for this post. See you in the next...

Make your own Python IDE + Text Editor like Notepad:

July 17, 2021, 4:33:43 PM (MrDev in a deep thought)

If you have used Python, you must be aware of the Python shell (the IDLE). We have one place where we write the code and to run the code, we need to switch between the windows. Some brilliant mind will say (with a sarcastic sound) "He calls himself a programmer and he is talking about IDLE... Lol hahaha."

Shut up! Okay? I use IDEs but something that you have made, even its worse than what you think that was worse, you will like that! And a programmer builds things. This is his work.

Now in this project, I created my own IDE with python using Tkinter.

Now let me assume that some of you are from Mars and they don't know what IDEs actually are? So basically, IDE stands for Integrated Development Environment. It provides a collection of different things needed for coding and creates an environment for coding fast. Well its obvious that I could not make something at once that can directly challenge VS code (one of the leading IDEs in). But I can make something more similar to a text editor (like Notepad). And basically, what we actually want in programming is a section to run the program and display the output. So, can't we combine the output and the editor part in the same window. So, it reduces our work to switch between the windows like we do in IDLE.

Well, that's all about the idea. I am going to create a new notepad. But don't laugh. Okay. It would have some more features than notepad. Believe me! Let's start!

>>> Test 1: ✔
>>> Test 2: ✔
>>> Test 3: ✔
>>> Test 4: ✔
...

Code Link

1 Comments

  1. Are you in Windows 10? This looks different

    ReplyDelete