Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

Commit 44d3ae3

Browse files
authored
Update main.py
Add more clarity to the code
1 parent 7888557 commit 44d3ae3

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

projects/Browser/main.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,58 @@
44
from PyQt5.QtWebEngineWidgets import *
55
import sys
66

7-
7+
# Define the main window class
88
class MainWindow(QMainWindow):
99
def __init__(self):
1010
super(MainWindow, self).__init__()
11+
12+
# Create a QWebEngineView widget
1113
self.browser = QWebEngineView()
1214
self.browser.setUrl(QUrl("http://www.google.com"))
1315
self.setCentralWidget(self.browser)
16+
17+
# Show the window maximized
1418
self.showMaximized()
19+
20+
# Create a navigation toolbar
1521
navbar = QToolBar()
1622
navbar.adjustSize()
1723
self.addToolBar(navbar)
24+
25+
# Add a back button to the toolbar
1826
back_btn = QAction("⮜", self)
1927
back_btn.triggered.connect(self.browser.back)
2028
navbar.addAction(back_btn)
21-
29+
30+
# Add a forward button to the toolbar
2231
forward_btn = QAction("⮞", self)
2332
forward_btn.triggered.connect(self.browser.forward)
2433
navbar.addAction(forward_btn)
25-
34+
35+
# Add a reload button to the toolbar
2636
reload_btn = QAction("⟳", self)
2737
reload_btn.triggered.connect(self.browser.reload)
2838
navbar.addAction(reload_btn)
29-
39+
40+
# Add a URL bar to the toolbar
3041
self.url_bar = QLineEdit()
3142
self.url_bar.returnPressed.connect(self.open_url)
3243
navbar.addWidget(self.url_bar)
44+
45+
# Update the URL bar when the browser URL changes
3346
self.browser.urlChanged.connect(self.update_url)
3447

48+
# Load the URL entered in the URL bar
3549
def open_url(self):
3650
url = self.url_bar.text()
3751
self.browser.setUrl(QUrl(url))
3852

53+
# Update the URL bar when the browser URL changes
3954
def update_url(self, q):
4055
self.url_bar.setText(q.toString())
4156

42-
57+
# Create the application and main window
4358
app = QApplication(sys.argv)
44-
4559
QApplication.setApplicationName("EFFLUX browser")
46-
4760
window = MainWindow()
48-
4961
app.exec_()

0 commit comments

Comments
 (0)