[python]Gui网页内嵌
需要插件
pip install pyinstaller
pip install PyQtWebEngine
pip install PyQt5
代码
import sys
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtWebEngineWidgets import *
class MainWindow(QMainWindow):
def __init__(self):
super(MainWindow, self).__init__()
self.setWindowTitle('哀.net')
self.setWindowIcon(QIcon('favicon.ico'))
# 设置窗口大小900*600
self.setMinimumSize(1366, 768)
self.setMaximumSize(1920, 1080)
self.show()
self.browser = QWebEngineView()
# 加载外部Web页面
self.browser.load(QUrl('https://x.com'))
self.setCentralWidget(self.browser)
if __name__ == '__main__':
app = QApplication(sys.argv)
win = MainWindow()
win.show()
sys.exit(app.exec_())
打包
pyinstaller -F -w --icon="favicon.ico" x.py