Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- from PySide import QtCore, QtGui, QtWebKit
- app = QtGui.QApplication([])
- class HtmlLabel(QtWebKit.QWebView):
- def __init__(self, parent=None):
- super(HtmlLabel, self).__init__(parent)
- palette = self.palette()
- palette.setBrush(QtGui.QPalette.Base, QtCore.Qt.transparent)
- self.setPalette(palette)
- #self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
- def sizeHint(self):
- return QtGui.QLabel.sizeHint
- mainWidget = QtGui.QWidget()
- mainWidget.setLayout(QtGui.QVBoxLayout())
- news = QtGui.QLabel()
- news.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
- news.setAlignment(QtCore.Qt.AlignCenter)
- news.setTextFormat(QtCore.Qt.RichText)
- news.setWordWrap(True)
- news.setOpenExternalLinks(True)
- webNews = HtmlLabel()
- mainWidget.layout().addWidget(news)
- mainWidget.layout().addWidget(webNews)
- html = '''<p><span style="font-size: 17px;"><span style="color: #993300;"><img style="margin-right: 15px; vertical-align: top;" src="https://pypi.python.org/static/images/python-3.png" alt="announcements" /><cite>some text that is pulled from a website but which will be quite simple.</cite></span></span></p>'''
- news.setText(html)
- webNews.setHtml(html)
- mainWidget.show()
- sys.exit(app.exec_())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement