Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PyQt5.QtCore import QUrl
- from PyQt5.QtWidgets import *
- from PyQt5.QtWebEngineWidgets import *
- app = QApplication([])
- class CustomPage(QWebEnginePage):
- widgets = []
- def acceptNavigationRequest(self, url, _type, isMainFrame):
- if _type == self.NavigationTypeLinkClicked:
- test = QLabel("Hello")
- test.show()
- self.widgets.append(test)
- return False
- return super().acceptNavigationRequest(url, _type, isMainFrame)
- content = ("<a href=''>click</a>")
- htmlWidget = QWebEngineView()
- page = CustomPage(htmlWidget)
- htmlWidget.setPage(page)
- # htmlWidget.setHtml(content)
- htmlWidget.load(QUrl("file:///home/kiba/projects/mvp/pyqt5/content-41.html"))
- htmlWidget.show()
- app.exec_()
Advertisement
Add Comment
Please, Sign In to add comment