本文整理匯總了Python中vistrails.gui.paramexplore.pe_pipeline.QAnnotatedPipelineView.drawId方法的典型用法代碼示例。如果您正苦於以下問題:Python QAnnotatedPipelineView.drawId方法的具體用法?Python QAnnotatedPipelineView.drawId怎麽用?Python QAnnotatedPipelineView.drawId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vistrails.gui.paramexplore.pe_pipeline.QAnnotatedPipelineView
的用法示例。
在下文中一共展示了QAnnotatedPipelineView.drawId方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: setCellData
# 需要導入模塊: from vistrails.gui.paramexplore.pe_pipeline import QAnnotatedPipelineView [as 別名]
# 或者: from vistrails.gui.paramexplore.pe_pipeline.QAnnotatedPipelineView import drawId [as 別名]
def setCellData(self, cellType, cellId):
""" setCellData(cellType: str, cellId: int) -> None Create an
image based on the cell type and id. Then assign it to the
label. If cellType is None, the cell will be drawn with
transparent background. If cellType is '', the cell will be
drawn with the caption 'Empty'. Otherwise, the cell will be
drawn with white background containing cellType as caption and
a small rounded shape on the lower right painted with cellId
"""
self.type = cellType
self.id = cellId
size = QtCore.QSize(*CurrentTheme.VIRTUAL_CELL_LABEL_SIZE)
image = QtGui.QImage(size.width() + 12,
size.height()+ 12,
QtGui.QImage.Format_ARGB32_Premultiplied)
image.fill(0)
font = QtGui.QFont()
font.setStyleStrategy(QtGui.QFont.ForceOutline)
painter = QtGui.QPainter()
painter.begin(image)
painter.setRenderHint(QtGui.QPainter.Antialiasing)
if self.type==None:
painter.setPen(QtCore.Qt.NoPen)
painter.setBrush(QtCore.Qt.NoBrush)
else:
if self.type=='':
painter.setPen(QtCore.Qt.gray)
painter.setBrush(QtCore.Qt.NoBrush)
else:
painter.setPen(QtCore.Qt.black)
painter.setBrush(QtCore.Qt.lightGray)
painter.drawRoundRect(QtCore.QRectF(0.5, 0.5, image.width()-1,
image.height()-1), 25, 25)
painter.setFont(font)
if self.type!=None:
painter.drawText(QtCore.QRect(QtCore.QPoint(6, 6), size),
QtCore.Qt.AlignCenter | QtCore.Qt.TextWrapAnywhere,
split_camel_case(self.type))
# Draw the lower right corner number if there is an id
if self.id>=0 and self.type:
QAnnotatedPipelineView.drawId(painter, image.rect(), self.id,
QtCore.Qt.AlignRight |
QtCore.Qt.AlignBottom)
painter.end()
self.setPixmap(QtGui.QPixmap.fromImage(image))
示例2: paint
# 需要導入模塊: from vistrails.gui.paramexplore.pe_pipeline import QAnnotatedPipelineView [as 別名]
# 或者: from vistrails.gui.paramexplore.pe_pipeline.QAnnotatedPipelineView import drawId [as 別名]
def paint(self, painter, option, index):
""" painter(painter: QPainter, option QStyleOptionViewItem,
index: QModelIndex) -> None
Repaint the top-level item to have a button-look style
"""
model = index.model()
if (model.parent(index).isValid()==False or
model.parent(index).parent().isValid()==False):
style = self.treeView.style()
r = option.rect
textrect = QtCore.QRect(r.left() + 10,
r.top(),
r.width() - 10,
r.height())
font = painter.font()
font.setBold(True)
painter.setFont(font)
text = option.fontMetrics.elidedText(
model.data(index, QtCore.Qt.DisplayRole),
QtCore.Qt.ElideMiddle,
textrect.width()-10)
style.drawItemText(painter,
textrect,
QtCore.Qt.AlignLeft,
option.palette,
self.treeView.isEnabled(),
text)
painter.setPen(QtGui.QPen(QtCore.Qt.black))
fm = QtGui.QFontMetrics(font)
size = fm.size(QtCore.Qt.TextSingleLine, text)
#painter.drawLine(textrect.left()-5,
# textrect.bottom()-1,
# textrect.left()+size.width()+5,
# textrect.bottom()-1)
annotatedId = model.data(index, QtCore.Qt.UserRole+1)
if annotatedId:
idRect = QtCore.QRect(
QtCore.QPoint(textrect.left()+size.width()+5,
textrect.top()),
textrect.bottomRight())
QAnnotatedPipelineView.drawId(painter, idRect,
annotatedId,
QtCore.Qt.AlignLeft |
QtCore.Qt.AlignVCenter)
else:
QtGui.QItemDelegate.paint(self, painter, option, index)