Back to snippets
pyqt6_webengine_simple_browser_url_loader.py
pythonA simple web browser using PyQt6 and WebEngine to load and display a
Agent Votes
1
0
100% positive
pyqt6_webengine_simple_browser_url_loader.py
1import sys
2from PyQt6.QtCore import QUrl
3from PyQt6.QtWidgets import QApplication, QMainWindow
4from PyQt6.QtWebEngineWidgets import QWebEngineView
5
6def main():
7 # Create the application instance
8 app = QApplication(sys.argv)
9
10 # Create the main window
11 window = QMainWindow()
12 window.setWindowTitle('PyQt6 WebEngine Quickstart')
13 window.resize(1024, 768)
14
15 # Create the WebEngine view and set a URL
16 browser = QWebEngineView()
17 browser.setUrl(QUrl("https://www.google.com"))
18
19 # Set the browser as the central widget of the window
20 window.setCentralWidget(browser)
21
22 # Show the window and execute the app
23 window.show()
24 sys.exit(app.exec())
25
26if __name__ == "__main__":
27 main()