本文整理汇总了Python中PyQt4.QtGui.QGraphicsSimpleTextItem类的典型用法代码示例。如果您正苦于以下问题:Python QGraphicsSimpleTextItem类的具体用法?Python QGraphicsSimpleTextItem怎么用?Python QGraphicsSimpleTextItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QGraphicsSimpleTextItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_items
def update_items(self):
self.item = QGraphicsRectItem(
0, 0, self.width, self.row_h * self.coeff_h)
seq_width = 0
nopen = QPen(Qt.NoPen)
self.item.setPen(nopen)
font = QFont(self.ftype, self.fsize)
if self.fstyle == "italic":
font.setStyle(QFont.StyleItalic)
elif self.fstyle == "oblique":
font.setStyle(QFont.StyleOblique)
rect_cls = QGraphicsRectItem
for i, val in enumerate(self.liste):
width = self.col_w
height = self.row_h * len(str(val)) + 1
rectitem = rect_cls(0, 0, width, height, parent=self.item)
rectitem.setX(seq_width) # to give correct X to children item
rectitem.setBrush(QBrush(QColor(self.bgcolor)))
rectitem.setPen(nopen)
# write letter if enough space in height
if height >= self.fsize:
text = QGraphicsSimpleTextItem(str(val), parent=rectitem)
text.setFont(font)
text.setBrush(QBrush(QColor(self.fgcolor)))
# Center text according to rectitem size
# txtw = text.boundingRect().width()
txth = text.boundingRect().height()
text.setRotation(self.rot)
text.setX(txth)
seq_width += width
self.width = seq_width
示例2: draw_x_axis
def draw_x_axis(self):
#lineItem = QGraphicsLineItem(self.col_w/2,
# self.coordY(self.ylim[0])+2,
# self.width-self.col_w/2,
# self.coordY(self.ylim[0])+2,
# parent=self.item)
#lineItem.setPen(QPen(QColor('black')))
#lineItem.setZValue(10)
#all_vals = list(range(0, len(self.values), 5))
#if (len(self.values)-1)%5:
# all_vals += [len(self.values)-1]
for x, lab in enumerate(self.values):
# lineItem = QGraphicsLineItem(0, self.coordY(self.ylim[0])+2,
# 0, self.coordY(self.ylim[0])+6,
# parent=self.item)
# lineItem.setX(x*self.col_w + self.col_w/2)
# lineItem.setPen(QPen(QColor('black')))
# lineItem.setZValue(10)
text = QGraphicsSimpleTextItem(str(lab))
text.rotate(-90)
text.setFont(QFont("Arial", self.fsize-2))
text.setParentItem(self.item)
tw = text.boundingRect().height()
# Center text according to masterItem size
text.setPos(x*self.col_w-tw/2 + self.col_w/2,
self.coordY(self.ylim[0]))
示例3: __init__
def __init__(self, longitude, latitude, text, scene, parent=None, min_zoom_visibility=None):
pos = scene.posFromLonLat(longitude, latitude)
QGraphicsSimpleTextItem.__init__(self, text, scene=scene, parent=parent)
self._min_zoom = min_zoom_visibility
self._lon, self._lat = longitude, latitude
self.setPos(pos)
self.updatePosition(scene)
示例4: __init__
def __init__(self, face, node, text):
QGraphicsSimpleTextItem.__init__(self, text)
_ActionDelegator.__init__(self)
self.node = node
self.face = face
self._bounding_rect = self.face.get_bounding_rect()
self._real_rect = self.face.get_real_rect()
示例5: paint
def paint( self, painter, option, widget ):
color = self.__settings.lineColor
if self.color:
color = self.color
self.setBrush( QBrush( color ) )
QGraphicsSimpleTextItem.paint( self, painter, option, widget )
return
示例6: __init__
def __init__( self, settings, text ):
QGraphicsSimpleTextItem.__init__( self )
self.__settings = settings
self.setFont( settings.badgeFont )
self.setText( text )
self.color = None
return
示例7: update_items
def update_items(self):
#self.item = QGraphicsRectItem(0,0,self._total_w, self.row_h)
seq_width = 0
nopen = QPen(QtCore.Qt.NoPen)
font = QFont("Courier", self.fsize)
rect_cls = self.InteractiveLetterItem if self.interact else QGraphicsRectItem
for i, letter in enumerate(self.seq):
width = self.col_w
for m in self.special_col:
if m[0] < i <= m[1]:
width = self.alt_col_w
break
#load interactive item if called correspondingly
rectItem = rect_cls(0, 0, width, self.row_h, parent=self.item)
rectItem.setX(seq_width) # to give correct X to children item
rectItem.setBrush(self.bg_col[letter])
rectItem.setPen(nopen)
if self.interact:
if self.codon:
rectItem.codon = '%s, %d: %s' % (self.seq[i], i,
self.codon[i*3:i*3+3])
else:
rectItem.codon = '%s, %d' % (self.seq[i], i)
# write letter if enough space
if width >= self.fsize:
text = QGraphicsSimpleTextItem(letter, parent=rectItem)
text.setFont(font)
text.setBrush(self.fg_col[letter])
# Center text according to rectItem size
tw = text.boundingRect().width()
th = text.boundingRect().height()
text.setPos((width - tw)/2, (self.row_h - th)/2)
seq_width += width
self.width = seq_width
示例8: __init__
def __init__(self, table, vector, mass=1.0):
"""Documentation here"""
self.name = table.name
self._mediator = Mediator()
# layout widget
x, y = vector.x, vector.y
text = QGraphicsSimpleTextItem('{0} as {1}'.format(self.name, self.alias))
width = text.boundingRect().width()
QGraphicsRectItem.__init__(self, x, y, width + 10, 22)
self.table = table.alias(self.alias)
self.setBrush(Qt.cyan)
self.setPen(Qt.darkCyan)
self.width = width + 10
self.height = 22
self.setFlag(self.ItemIsSelectable, True)
text.setParentItem(self)
text.setX(x + 5)
text.setY(y + 5)
self.point = vector
self.mass = mass
self.velocity = Vector(0, 0)
self.force = Vector(0, 0)
self.instances.append(self)
示例9: set_labels
def set_labels(self, labels):
"""Set the text labels."""
self.clear()
orientation = Qt.Horizontal if self.orientation == Qt.Vertical else Qt.Vertical
for text in labels:
item = QGraphicsSimpleTextItem(text, self)
item.setFont(self.font())
item.setToolTip(text)
witem = WrapperLayoutItem(item, orientation, parent=self)
self.layout().addItem(witem)
self.layout().setAlignment(witem, self.alignment)
self.label_items.append(item)
self.layout().activate()
self.updateGeometry()
示例10: showMoveHelper
def showMoveHelper(self, visible=True):
"""show help text In empty HandBoards"""
if visible:
if not self.__moveHelper:
splitter = QGraphicsRectItem(self)
hbCenter = self.rect().center()
splitter.setRect(hbCenter.x() * 0.5, hbCenter.y(), hbCenter.x() * 1, 1)
helpItems = [splitter]
for name, yFactor in [(m18n('Move Exposed Tiles Here'), 0.5),
(m18n('Move Concealed Tiles Here'), 1.5)]:
helper = QGraphicsSimpleTextItem(name, self)
helper.setScale(3)
nameRect = QRectF()
nameRect.setSize(helper.mapToParent(helper.boundingRect()).boundingRect().size())
center = QPointF(hbCenter)
center.setY(center.y() * yFactor)
helper.setPos(center - nameRect.center())
if self.sceneRotation() == 180:
rotateCenter(helper, 180)
helpItems.append(helper)
self.__moveHelper = self.scene().createItemGroup(helpItems)
self.__moveHelper.setVisible(True)
else:
if self.__moveHelper:
self.__moveHelper.setVisible(False)
示例11: setPageHead
def setPageHead(self, len):
count = 0
x = 95
while count < len:
item = QGraphicsSimpleTextItem()
item.setFont(self.font)
item.setText("%.2x" % count)
item.setPos(x, 3)
self.scene.addItem(item)
x += self.pagew + 2
count += 1
示例12: setNumber
def setNumber(self):
"""docstring for setNumber"""
if self.label == None:
self.label = QGraphicsSimpleTextItem("%d" % self._number)
self.label.setFont(self.font)
self.label.setParentItem(self)
y_val = self.radius / 3
if self._number < 10:
self.label.setPos(self.radius / 1.5, y_val)
elif self._number < 100:
self.label.setPos(self.radius / 3, y_val)
else: # _number >= 100
self.label.setPos(0, y_val)
示例13: __init__
def __init__(self, pathHelixGroup):
super(ActiveSliceHandle, self).__init__(pathHelixGroup)
self._pathHelixGroup = None
self._activeSlice = 0
self._dragMode = False
self._label = QGraphicsSimpleTextItem("", parent=self)
self._label.setPos(0, -18)
self._label.setFont(self._myfont)
self._label.setBrush(self._labelbrush)
self._label.hide()
self.setPathHelixGroup(pathHelixGroup)
self.setFlag(QGraphicsItem.ItemIsMovable)
self.setAcceptHoverEvents(True)
self.setZValue(styles.ZACTIVESLICEHANDLE)
示例14: ugly_name_face
def ugly_name_face(node, *args, **kargs):
""" This is my item generator. It must receive a node object, and
returns a Qt4 graphics item that can be used as a node face.
"""
# receive an arbitrary number of arguments, in this case width and
# height of the faces
width = args[0][0]
height = args[0][1]
## Creates a main master Item that will contain all other elements
## Items can be standard QGraphicsItem
# masterItem = QGraphicsRectItem(0, 0, width, height)
# Or your custom Items, in which you can re-implement interactive
# functions, etc. Check QGraphicsItem doc for details.
masterItem = InteractiveItem(0, 0, width, height)
# Keep a link within the item to access node info
masterItem.node = node
# I dont want a border around the masterItem
masterItem.setPen(QPen(QtCore.Qt.NoPen))
# Add ellipse around text
ellipse = QGraphicsEllipseItem(masterItem.rect())
ellipse.setParentItem(masterItem)
# Change ellipse color
ellipse.setBrush(QBrush(QColor( random_color())))
# Add node name within the ellipse
text = QGraphicsSimpleTextItem(node.name)
text.setParentItem(ellipse)
text.setPen(QPen(QPen(QColor("white"))))
# Center text according to masterItem size
tw = text.boundingRect().width()
th = text.boundingRect().height()
center = masterItem.boundingRect().center()
text.setPos(center.x()-tw/2, center.y()-th/2)
return masterItem
示例15: __init__
def __init__(self, parentPH, fromStrand, fromIdx, toVH, toIdx, orientedLeft):
super(PreCrossoverHandle, self).__init__(parentPH)
self.fromVH = parentPH.vhelix()
self.fromStrand = fromStrand
self.fromIdx = fromIdx
self.toVH = toVH
self.toIdx = toIdx
self.orientedLeft = orientedLeft
self.fromVH.basesModified.connect(self.updateVisibilityAndEnabledness)
self.toVH.basesModified.connect(self.updateVisibilityAndEnabledness)
self.label = QGraphicsSimpleTextItem(str(toVH.number()), parent=self)
self.label.setFont(self.toHelixNumFont)
x = self.baseWidth * self.fromIdx
y = (-1.25 if self.onTopStrand() else 2.25) * self.baseWidth
self.setPos(x, y)
halfLabelW = self.label.boundingRect().width() / 2
labelX = self.baseWidth/2 - halfLabelW
labelY = (-.10 if self.onTopStrand() else .48) * self.baseWidth
self.label.setPos(labelX, labelY)
self.updateVisibilityAndEnabledness()