def paintEvent(self, event=None):
painter = QtGui.QPainter(self)
if self.color is not None:
painter.setBrush(QtGui.QBrush(self.color))
rect = self.rect()
margins = self.contentsMargins()
new_rect = QtCore.QRect(rect.left()+margins.left(),
rect.top()+margins.top(),
rect.width()-margins.right()*2,
rect.height()-margins.bottom()*2)
painter.drawRect(new_rect)
评论列表
文章目录