Advertisement
Guest User

Untitled

a guest
Nov 11th, 2013
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.28 KB | None | 0 0
  1. import sys
  2. from PySide import QtCore, QtGui, QtWebKit
  3.  
  4. app = QtGui.QApplication([])
  5.  
  6. class HtmlLabel(QtWebKit.QWebView):
  7.     def __init__(self, parent=None):
  8.         super(HtmlLabel, self).__init__(parent)
  9.         palette = self.palette()
  10.         palette.setBrush(QtGui.QPalette.Base, QtCore.Qt.transparent)
  11.         self.setPalette(palette)
  12.         #self.setAttribute(QtCore.Qt.WA_TranslucentBackground)        
  13.    
  14.     def sizeHint(self):
  15.         return QtGui.QLabel.sizeHint
  16.  
  17. mainWidget = QtGui.QWidget()
  18. mainWidget.setLayout(QtGui.QVBoxLayout())
  19.  
  20. news = QtGui.QLabel()
  21. news.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
  22. news.setAlignment(QtCore.Qt.AlignCenter)
  23. news.setTextFormat(QtCore.Qt.RichText)
  24. news.setWordWrap(True)
  25. news.setOpenExternalLinks(True)
  26.  
  27. webNews = HtmlLabel()
  28.  
  29. mainWidget.layout().addWidget(news)
  30. mainWidget.layout().addWidget(webNews)
  31.  
  32. 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>'''
  33. news.setText(html)
  34. webNews.setHtml(html)
  35.  
  36. mainWidget.show()
  37.  
  38. sys.exit(app.exec_())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement