Guest User

Untitled

a guest
Oct 20th, 2013
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.78 KB | None | 0 0
  1. class StatusWidgetBar(QtGui.QComboBox):
  2.     def __init__(self, parent=None):
  3.         super(StatusWidgetBar, self).__init__(parent)
  4.         self.setToolTip('status (click to edit)')
  5.         self.addItems(['waiting', 'in progress', 'finished'])
  6.  
  7.    
  8.     def paintEvent(self, event):
  9.         painter = QtGui.QPainter(self)
  10.         painter.setRenderHint(QtGui.QPainter.Antialiasing)
  11.         parent = self.parentWidget()
  12.         progress = self.currentIndex() * .5
  13.  
  14.         painter.setPen(QtGui.QColor(0,0,0,0))
  15.         if progress <= .5:
  16.             painter.setBrush(QtGui.QColor(255, 140, 30))
  17.         else:
  18.             painter.setBrush(QtGui.QColor('darkGreen'))
  19.  
  20.         barRect = QtCore.QRect(0, 0, (self.width()) * progress, self.height())
  21.         painter.drawRect(barRect)
Advertisement
Add Comment
Please, Sign In to add comment