import os
import sys
from PyQt5 import QtGui
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QApplication, QLabel, QWidget
from PyQt5.QtWebEngineWidgets import *
from PyQt5.QtWebEngineCore import *
from PyQt5.QtCore import QUrl
from PyQt5.QtWebEngineWidgets import QWebEnginePage
class Window(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle("Icon Modes")
self.setGeometry(300, 300, 500, 400)
def setIcon(self):
appIcon = QIcon("./baitao.ico")
self.setWindowIcon(appIcon)
def setIconModes(self):
icon1 = QIcon("./baitao.ico")
label1 = QLabel('Sample', self)
pixmap1 = icon1.pixmap(100, 100, QIcon.Active, QIcon.On)
label1.setPixmap(pixmap1)
icon2 = QIcon("./baitao.ico")
label2 = QLabel('Sample', self)
pixmap2 = icon2.pixmap(100, 100, QIcon.Disabled, QIcon.Off)
label2.setPixmap(pixmap2)
label2.move(100, 0)
icon3 = QIcon("./baitao.ico")
label3 = QLabel('Sample', self)
pixmap3 = icon3.pixmap(100, 100, QIcon.Selected, QIcon.On)
label3.setPixmap(pixmap3)
label3.move(200, 0)
def addIco(self, page):
print(page.icon())
print(page.iconUrl())
class WebEngineUrlRequestInterceptor(QWebEngineUrlRequestInterceptor):
def __init__(self, parent=None):
super().__init__(parent)
def interceptRequest(self, info):
print(info.requestUrl(), info.requestMethod(), info.resourceType(), info.firstPartyUrl())
def tt(page, aaaaaa):
print(page)
print(page.objectName())
print(page.dynamicPropertyNames())
print(page.title())
print(page.icon())
print(page.url().url())
page.setWindowIcon(page.icon())
page.setWindowTitle(page.title())
#aaaaaa.show()
if __name__ == '__main__':
app = QApplication(sys.argv)
aaaaaa = Window()
aaaaaa.setIcon()
aaaaaa.setIconModes()
page = QWebEngineView()
page.setUrl(QUrl(
"https://music.163.com/"))
# t = WebEngineUrlRequestInterceptor()
# page.profile().setRequestInterceptor(t)
page.loadFinished.connect(lambda: tt(page, aaaaaa))
page.resize(600, 400)
page.show()
sys.exit(app.exec_())
这样设置没有效果,请问哪位大神知道