Please place the following in a file test.py:
import sys
from PyQt6.QtWidgets import QApplication, QMainWindow
from PyQt6.QtWebEngineWidgets import QWebEngineView
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("Hello, World! - PyQtWebEngine")
self.resize(800, 600)
# Create a QWebEngineView widget
self.browser = QWebEngineView()
# Set the HTML content for the browser
html_content = """
<!DOCTYPE html>
<html>
<head>
<title>Hello, World!</title>
</head>
<body>
<h1 style="text-align: center; margin-top: 20%;">Hello, World!</h1>
</body>
</html>
"""
self.browser.setHtml(html_content)
# Set the browser as the central widget
self.setCentralWidget(self.browser)
if __name__ == "__main__":
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec())
Then run it using python.exe inside the venv you created. Do you see “Hello World” there?