当前位置: 首页>>代码示例>>Python>>正文


Python QItemDelegate.paint方法代码示例

本文整理汇总了Python中PyQt4.QtGui.QItemDelegate.paint方法的典型用法代码示例。如果您正苦于以下问题:Python QItemDelegate.paint方法的具体用法?Python QItemDelegate.paint怎么用?Python QItemDelegate.paint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt4.QtGui.QItemDelegate的用法示例。


在下文中一共展示了QItemDelegate.paint方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: paint

# 需要导入模块: from PyQt4.QtGui import QItemDelegate [as 别名]
# 或者: from PyQt4.QtGui.QItemDelegate import paint [as 别名]
 def paint(self, painter, option, index):
 
     if index.column() != 0:
         QItemDelegate.paint(self, painter, option, index)
         return
     
     painter.fillRect(option.rect, option.palette.brush(QPalette.Base))
     painter.setPen(QPen(option.palette.color(QPalette.Text)))
     painter.drawText(option.rect.adjusted(4, 4, -4, -4),
         Qt.TextShowMnemonic | Qt.AlignLeft | Qt.AlignVCenter,
         index.data().toString())
开发者ID:RaphaelRochet,项目名称:puddletag,代码行数:13,代码来源:shortcutsettings.py

示例2: paint

# 需要导入模块: from PyQt4.QtGui import QItemDelegate [as 别名]
# 或者: from PyQt4.QtGui.QItemDelegate import paint [as 别名]
 def paint(self, painter, option, index):
     option.palette.setColor(
         QPalette.Highlight,QColor(
             index.data(Qt.BackgroundRole)).darker(107))
     option.palette.setColor(
         QPalette.HighlightedText,QColor(
             index.data(Qt.ForegroundRole)).darker(115))
     QItemDelegate.paint(self, painter, option, index)
     if option.showDecorationSelected and \
             (option.state & QStyle.State_Selected):
         painter.drawRect(option.rect)
开发者ID:Araneidae,项目名称:iocbuilder,代码行数:13,代码来源:delegates.py

示例3: paint

# 需要导入模块: from PyQt4.QtGui import QItemDelegate [as 别名]
# 或者: from PyQt4.QtGui.QItemDelegate import paint [as 别名]
 def paint (self, painter, option, index):
     if not (QStyle.State_Selected & option.state):
         r = QRect(option.rect)
         r.setX(0)
         # test if item/device is in use
         if index.data(Qt.UserRole).toBool():
             painter.setBrush(QColor(255, 0, 0, 32))
         else:
             painter.setBrush(QColor(0, 255, 0, 128))
         painter.setPen(Qt.lightGray)
         painter.drawRect(r)
     QItemDelegate.paint(self, painter, option, index)
开发者ID:ibressler,项目名称:dfmon,代码行数:14,代码来源:uiqt.py

示例4: paint

# 需要导入模块: from PyQt4.QtGui import QItemDelegate [as 别名]
# 或者: from PyQt4.QtGui.QItemDelegate import paint [as 别名]
 def paint(self,painter,option,index):
     if index.column() == 1:
         progress = int(index.model().data(index, Qt.DisplayRole))
         progressBarOption = QStyleOptionProgressBarV2()
         progressBarOption.state = QStyle.State_Enabled
         progressBarOption.direction = QApplication.layoutDirection()
         progressBarOption.rect = option.rect
         progressBarOption.fontMetrics = QApplication.fontMetrics()
         progressBarOption.textVisible = True
         progressBarOption.textAlignment = Qt.AlignCenter
         progressBarOption.minimum = 0
         row = index.row()
         maximum = index.model().record(row).value('size')
         if maximum == '未知':
             progressBarOption.maximum = 10000000
             progressBarOption.text = '0%'
             progressBarOption.progress = 0
         else:
             progressBarOption.maximum = int(maximum)
             progressBarOption.progress = progress
             ratio = int(progress*100/int(maximum))
             progressBarOption.text = '%s'%ratio+'%'
         QApplication.style().drawControl(QStyle.CE_ProgressBar,progressBarOption,painter)
     elif index.column() == 2:
         if index.model().data(index) != '未知':
             length = int(index.model().data(index, Qt.EditRole))
             lengthMB = length/(1024*1024)
             size = round(lengthMB, 1)
             text = '%s'%size+'M'
             QApplication.style().drawItemText(painter, option.rect, Qt.AlignLeft and Qt.AlignVCenter, QApplication.palette(), True, text)
         else:
             return QItemDelegate.paint(self,painter,option,index)
     elif index.column() == 3 :
         if index.model().data(index) not in ["已完成", "已取消", "等待", "已暂停", "出错"]:
             remainSeconds = float(index.model().data(index))
             hours = int(remainSeconds/3600)
             minutes = int((remainSeconds%3600)/60)
             seconds = round((remainSeconds)%3600%60, 1)
             if remainSeconds >= 3600:
                 remainTime = '%sh%sm%ss'%(hours, minutes, int(seconds))
             elif  remainSeconds < 3600 and remainSeconds >= 60:
                 remainTime = '%sm%ss'%(minutes, int(seconds))
             else:
                 remainTime = '%ss'%seconds
             text = remainTime
             QApplication.style().drawItemText(painter, option.rect, Qt.AlignLeft and Qt.AlignVCenter, QApplication.palette(), True, text)
         else:
             return QItemDelegate.paint(self,painter,option,index)
     else:
         return QItemDelegate.paint(self,painter,option,index)
开发者ID:xuhuairuogu,项目名称:xyplayer-package,代码行数:52,代码来源:mytables.py

示例5: paint

# 需要导入模块: from PyQt4.QtGui import QItemDelegate [as 别名]
# 或者: from PyQt4.QtGui.QItemDelegate import paint [as 别名]
    def paint(self, painter, option, index):
        """ Draw a button-style on root items """
        model = index.model()
        assert model


        if not model.parent(index).isValid():
            # this is a top-level item.
            buttonOption = QStyleOptionButton()

            buttonOption.state = option.state
            buttonOption.state &= ~QStyle.State_HasFocus

            buttonOption.rect = option.rect
            buttonOption.palette = option.palette
            buttonOption.features = QStyleOptionButton.None

            self.m_view.style().drawControl(QStyle.CE_PushButton, buttonOption, painter, self.m_view)

            branchOption = QStyleOption()
            i = 15  ### hardcoded in qcommonstyle.cpp
            r = option.rect
            branchOption.rect = QRect(r.left() + i/2, r.top() + (r.height() - i)/2, i, i)
            branchOption.palette = option.palette
#            branchOption.state = QStyle.State_Children

            if self.m_view.isExpanded(index):
                branchOption.state |= QStyle.State_Open

            self.m_view.style().drawPrimitive(QStyle.PE_IndicatorBranch, branchOption, painter, self.m_view)

            # draw text
            textrect = QRect(r.left() + i*2, r.top(), r.width() - ((5*i)/2), r.height())
            text = self.elidedText(option.fontMetrics, textrect.width(), Qt.ElideMiddle,
                              model.data(index, Qt.DisplayRole).toString())
            self.m_view.style().drawItemText(painter, textrect,Qt.AlignLeft|Qt.AlignVCenter,
                                             option.palette, self.m_view.isEnabled(), text)

            icon_variant = index.data(Qt.DecorationRole)
            icon = QIcon(icon_variant)
            self.m_view.style().drawItemPixmap(
                                               painter, option.rect,
                                               Qt.AlignLeft,
                                               icon.pixmap(icon.actualSize(QSize(20 ,20)))
                                               )

        else:
            QItemDelegate.paint(self, painter, option, index)
开发者ID:maximerobin,项目名称:Ufwi,代码行数:50,代码来源:pages_list.py

示例6: paint

# 需要导入模块: from PyQt4.QtGui import QItemDelegate [as 别名]
# 或者: from PyQt4.QtGui.QItemDelegate import paint [as 别名]
 def paint(self, painter, option, index):
     data = index.model().data(index, Qt.UserRole)
     if data.isValid() and data.toPyObject() is not None:
         data = data.toPyObject()
         painter.save()
         rect = option.rect
         rect.adjust(+5, 0, -5, 0)
         pen = data
         painter.setPen(pen)
         middle = (rect.bottom() + rect.top()) / 2
         painter.drawLine(rect.left(), middle, rect.right(), middle)
         painter.restore()
     else:
         QItemDelegate.paint(self, painter, option, index)
         painter.drawLine(rect.left(), middle, rect.right(), middle)
         painter.restore()
开发者ID:karstenv,项目名称:manageR,代码行数:18,代码来源:plugins_dialog.py

示例7: paint

# 需要导入模块: from PyQt4.QtGui import QItemDelegate [as 别名]
# 或者: from PyQt4.QtGui.QItemDelegate import paint [as 别名]
    def paint(self, painter, option, index):
        """ Framework hook to paint an editor.

        @param painter QPainter instance
        @param option QStyleOptionViewItem instance
        @param index QModelIndex instance of the item for the editor widget
        @return None
        """
        if index.column() not in self.columns:
            return QItemDelegate.paint(self, painter, option, index)
开发者ID:InfiniteAlpha,项目名称:profitpy,代码行数:12,代码来源:accountsummary.py

示例8: paint

# 需要导入模块: from PyQt4.QtGui import QItemDelegate [as 别名]
# 或者: from PyQt4.QtGui.QItemDelegate import paint [as 别名]
	def paint(self, painter, option, index):
		if index.column() in (SRC_ADDR, DST_ADDR):
			text = index.model().data(index).toString()
			palette = QApplication.palette()
			document = QTextDocument()
			document.setDefaultFont(option.font)
			if option.state & QStyle.State_Selected:
				document.setHtml("<font color=%s>%s</font>" % 
								(palette.highlightedText().color().name(), text))
				color = palette.highlight().color()
			else:
				document.setHtml(text)
				color = QColor(index.model().data(index, Qt.BackgroundColorRole))
			#document.setPageSize(option.rect.size())
			painter.save()
			painter.fillRect(option.rect, color)
			painter.translate(option.rect.x(), option.rect.y())
			document.drawContents(painter)
			painter.restore()
		else:
			QItemDelegate.paint(self, painter, option, index)
开发者ID:grucha,项目名称:Sniffer,代码行数:23,代码来源:packets.py

示例9: paint

# 需要导入模块: from PyQt4.QtGui import QItemDelegate [as 别名]
# 或者: from PyQt4.QtGui.QItemDelegate import paint [as 别名]
 def paint(self, painter, option, index):
     """custom painter for progress state """
     if index.column() == 1:
         # get value
         progress = index.model().data(index,Qt.DisplayRole)
         
         # calculate where to put the painted rect
         fullRect = option.rect
         center = fullRect.center()
         newRect = QRectF()
         newRect.setTop(     center.y() - 5  )
         newRect.setBottom(  center.y() + 5  )
         newRect.setLeft(    center.x() - 10 )
         newRect.setRight(   center.x() + 10 )
         
         color = self._getColorForProgress(progress)
         # paint
         painter.save()
         painter.fillRect(newRect, color)
         painter.translate(option.rect.x(), option.rect.y()+5)
         painter.restore()
     else:
         QItemDelegate.paint(self,painter,option,index)
开发者ID:toyg,项目名称:plasmaapplets,代码行数:25,代码来源:main.py

示例10: paint

# 需要导入模块: from PyQt4.QtGui import QItemDelegate [as 别名]
# 或者: from PyQt4.QtGui.QItemDelegate import paint [as 别名]
 def paint(self, painter, option, index):
     palette = option.palette
     color_select = palette.brush(QPalette.Highlight)
     if not index.model().isValid(index):
         palette.setBrush(QPalette.Highlight, QBrush(QColor(170,0,255)))
     return QItemDelegate.paint(self, painter, option, index)
开发者ID:PierreBdR,项目名称:point_tracker,代码行数:8,代码来源:timemodel.py

示例11: paint

# 需要导入模块: from PyQt4.QtGui import QItemDelegate [as 别名]
# 或者: from PyQt4.QtGui.QItemDelegate import paint [as 别名]
 def paint(self, painter, option, index):
     delegate = self.delegates.get(index.column())
     if delegate is not None:
         delegate.paint(painter, option, index)
     else:
         QItemDelegate.paint(self, painter, option, index)
开发者ID:maximerobin,项目名称:Ufwi,代码行数:8,代码来源:genericdelegates.py


注:本文中的PyQt4.QtGui.QItemDelegate.paint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。