from PyQt5.QtCore import QUrl
from PyQt5.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QWidget
from PyQt5.QtWebEngineWidgets import QWebEngineView
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("Ad Example")
self.setGeometry(100, 100, 800, 600)
# Create a web view widget
self.web_view = QWebEngineView()
# Read the HTML content from the index.html file
with open("index.html", "r") as file:
html_content = file.read()
# Load the HTML content into the web view
self.web_view.setHtml(html_content, QUrl.fromLocalFile("index.html"))
# Add the web view widget to the main window's layout
layout = QVBoxLayout()
layout.addWidget(self.web_view)
central_widget = QWidget()
central_widget.setLayout(layout)
self.setCentralWidget(central_widget)
if __name__ == "__main__":
app = QApplication([])
window = MainWindow()
window.show()
app.exec_()