Guest User

Untitled

a guest
Oct 20th, 2013
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from PyQt4 import QtCore, QtGui
  2.  
  3.  
  4. class StatusWidgetBar(QtGui.QComboBox):
  5.     def __init__(self, parent=None):
  6.         super(StatusWidgetBar, self).__init__(parent)
  7.         self.setToolTip('status (click to edit)')
  8.         self.addItems(['waiting', 'in progress', 'finished'])
  9.  
  10.     def paintEvent(self, event):
  11.         super(StatusWidgetBar, self).paintEvent(event)
  12.         painter = QtGui.QPainter(self)
  13.         progressBarStyleOption = QtGui.QStyleOptionProgressBar()
  14.         progressBarStyleOption.rect = QtCore.QRect(0, 0, (self.width()), self.height())
  15.         progressBarStyleOption.minimum = 0
  16.         progressBarStyleOption.maximum = self.count()
  17.         progressBarStyleOption.textAlignment = QtCore.Qt.AlignCenter
  18.         progressBarStyleOption.progress = self.currentIndex()
  19.         progressBarStyleOption.textVisible = True
  20.         painter.setOpacity(0.5)
  21.         QtGui.qApp.style().drawControl(QtGui.QStyle.CE_ProgressBar, progressBarStyleOption, painter)
  22.  
  23.  
  24. app = QtGui.QApplication([])
  25. w = StatusWidgetBar()
  26. w.show()
  27. app.exec_()
Advertisement
Add Comment
Please, Sign In to add comment