如下初步使用了pyqt5,构造了一个webview来加载网址,呈现网页。
1.安装pyqt5包,可使用douban的源
pip install pyqt5 -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
2.上代码如下
#!/usr/bin/python # -*- coding:utf-8 -*- import sys from PyQt5.QtCore import * from PyQt5.QtWidgets import * from PyQt5.QtWebKitWidgets import * class Form(QWidget): def __init__(self, parent=None): super(Form, self).__init__(parent) # self.setWindowOpacity(1) # self.setWindowFlags(Qt.FramelessWindowHint) # self.setAttribute(Qt.WA_TranslucentBackground) # self.showFullScreen() rect = QApplication.desktop().screenGeometry() self.resize(rect.width(), rect.height()) self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint) self.webview = QWebView() vbox = QVBoxLayout() vbox.addWidget(self.webview) main = QGridLayout() main.setSpacing(0) main.addLayout(vbox, 0, 0) self.setLayout(main) # self.setWindowTitle("CoDataHD") # webview.load(QUrl('http://www.cnblogs.com/misoag/archive/2013/01/09/2853515.html')) # webview.show() def load(self, url): self.webview.load(QUrl(url)) self.webview.show() if __name__ == '__main__': app = QApplication(sys.argv) screen = Form() screen.show() url = "https://www.baidu.com" screen.load(url) sys.exit(app.exec_())