コード例 #1
0
ファイル: mydelegate.py プロジェクト: kekfic/mytunefy
    def paint(self, painter, option, index):

        if index.column() == 0:
            painter.save()
            icon = QtGui.QIcon()
            icon.addPixmap(
                QtGui.QPixmap(":/spotify/resources/icons/play_lgrey.png"),
                QtGui.QIcon.Normal, QtGui.QIcon.Off)
            palette = QApplication.palette()
            opt = QStyleOptionButton()
            opt.icon = icon
            opt.iconSize = QtCore.QSize(30, 30)
            opt.rect = option.rect

            color = palette.highlight().color() \
                if option.state & QStyle.State_Selected \
                else QtGui.QColor(index.model().data(index, Qt.BackgroundColorRole))

            if self._pressed and self._pressed == (index.row(),
                                                   index.column()):
                opt.state = QStyle.State_Enabled | QStyle.State_Sunken
                opt.icon = icon

            elif self._hover and self._hover == (index.row(), index.column()):
                print('oh man')
                opt.icon = icon
            else:
                opt.state = QStyle.State_Enabled | QStyle.State_Raised
            QApplication.style().drawControl(QStyle.CE_PushButtonLabel, opt,
                                             painter)
            painter.restore()
        else:
            QStyledItemDelegate.paint(self, painter, option, index)
コード例 #2
0
 def paint(self, painter, option, index):
     painter.save()
     opt = QStyleOptionButton()
     opt.text = str(index.data())
     opt.rect = option.rect
     opt.palette = option.palette
     task = self.__taskStorage.getTaskByNum(index.row())
     if task.state != "RUN":
         opt.state = QStyle.State_Enabled | QStyle.State_Raised
     else:
         opt.state = QStyle.State_Enabled | QStyle.State_Sunken
     QApplication.style().drawControl(QStyle.CE_PushButton, opt, painter)
     painter.restore()
コード例 #3
0
ファイル: __init__.py プロジェクト: wuyue92tree/nice-you-get
    def paintSection(self, painter, rect, logicalIndex):
        painter.save()
        QHeaderView.paintSection(self, painter, rect, logicalIndex)
        painter.restore()

        if logicalIndex == 0:
            option = QStyleOptionButton()
            option.rect = QRect(3, 7, 10, 10)
            if self.isOn:
                option.state = QStyle.State_On
            else:
                option.state = QStyle.State_Off
            self.style().drawControl(QStyle.CE_CheckBox, option, painter)
コード例 #4
0
 def paintEvent(self, e):
     """ Draws the render setup button """
     painter = QPainter(self)
     option = QStyleOptionButton()
     option.initFrom(self)
     if self.isDown():
         option.state = QStyle.State_Sunken
     else:
         option.state = QStyle.State_Raised
      
     if self.enter:
         option.state = option.state | QStyle.State_MouseOver
      
     option.icon = self.icon()
     self.drawControl(QStyle.CE_PushButton, option, painter, self)
コード例 #5
0
 def paint(self, painter, option, index):
     painter.save()
     opt = QStyleOptionButton()
     opt.text = str(index.data())
     opt.rect = option.rect
     opt.palette = option.palette
     opt.state = QStyle.State_Enabled | QStyle.State_Raised
     QApplication.style().drawControl(QStyle.CE_PushButton, opt, painter)
     painter.restore()