PyQt5最全65 Web之使用QWebEngineView浏览器控件显示网页
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtWebEngineWidgets import *
import sys
class WebEngineView(QMainWindow):
"""
用Web浏览器(QWebEngineView)显示网页
PyQt5和Web的交互技术
同时使用Python和Web开发程序,混合开发
Python+JavaScript+HTML5+CSS
QWebEngineView用来显示Web界面
"""
def __init__(self):
super(WebEngineView, self).__init__()
self.setWindowTitle('打开外部网页例子')
self.setGeometry(5, 30, 1355, 730)
self.browser = QWebEngineView()
self.browser.load(QUrl('https://www.baidu.com/'))
self.setCentralWidget(self.browser)
if __name__ == '__main__':
app = QApplication(sys.argv)
main = WebEngineView()
print(main.__doc__)
main.show()
sys.exit(app.exec_())
结果