码迷,mamicode.com
首页 > Web开发 > 详细

pyqt 渲染html

时间:2018-11-01 11:44:46      阅读:507      评论:0      收藏:0      [点我收藏+]

标签:color   加载   geometry   hello   name   oct   ati   browser   try   

 

from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtWebEngineWidgets import *
import sys

class MainWindow(QMainWindow):

    def __init__(self ):
        super(QMainWindow, self).__init__()
        self.setWindowTitle(QWebView打开网页例子)
        self.setGeometry(5, 30, 1355, 730)
        #self.browser = QWebEngineView()
        #1 加载html代码
        self.browser = QWebEngineView()
        self.browser.setHtml(‘‘‘
        <!DOCTYPE html>
        <html>
            <head>
                <meta charset="UTF-8">
                <title></title>
            </head>
            <body>
                <h1>Hello PyQt5</h1>
                <h1>Hello PyQt5</h1>
                <h1>hello PyQt5</h1>
                <h1>hello PyQt5</h1>
                <h1>hello PyQt5</h1>
                <h1>Hello PyQt5</h1>
                
            </body>
        </html>

        ‘‘‘
        )
        
        self.setCentralWidget(self.browser)

if __name__ == __main__:
    app = QApplication(sys.argv)
    
    win = MainWindow()
    win.show()
    sys.exit(app.exec_())

 

pyqt 渲染html

标签:color   加载   geometry   hello   name   oct   ati   browser   try   

原文地址:https://www.cnblogs.com/sea-stream/p/9886729.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!