本文整理汇总了Python中PyQt5.QtWidgets.QGraphicsTextItem.show方法的典型用法代码示例。如果您正苦于以下问题:Python QGraphicsTextItem.show方法的具体用法?Python QGraphicsTextItem.show怎么用?Python QGraphicsTextItem.show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QGraphicsTextItem
的用法示例。
在下文中一共展示了QGraphicsTextItem.show方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addWP
# 需要导入模块: from PyQt5.QtWidgets import QGraphicsTextItem [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsTextItem import show [as 别名]
def addWP(self, wp):
if wp.command in [mavutil.mavlink.MAV_CMD_NAV_WAYPOINT,
mavutil.mavlink.MAV_CMD_NAV_WAYPOINT,
mavutil.mavlink.MAV_CMD_NAV_LOITER_TO_ALT,
mavutil.mavlink.MAV_CMD_NAV_LOITER_TURNS,
mavutil.mavlink.MAV_CMD_NAV_LOITER_TIME,
mavutil.mavlink.MAV_CMD_NAV_LOITER_UNLIM,
mavutil.mavlink.MAV_CMD_NAV_LAND]:
#point
rad = self.__wp_diameter * 0.5
ellipse = QGraphicsEllipseItem(wp.y - rad, -wp.x - rad,
self.__wp_diameter, self.__wp_diameter, self.__mission_layer)
ellipse.setBrush(QBrush(QColor(255, 255, 255)))
e_pen = QPen(QColor(255, 255, 255))
e_pen.setWidth(0)
ellipse.setPen(e_pen)
self.__mission_layer.addToGroup(ellipse)
#label
label = QGraphicsTextItem(str(wp.seq), self.__mission_layer)
label.setZValue(2)
label.setDefaultTextColor(Qt.white)
label.setPos(wp.y + rad, -wp.x - rad)
label.setScale(0.00002) #bit hacky -- really should scale based on
#current zoom, but I'm in a hurry.
self.__mission_layer.addToGroup(label)
label.show()
示例2: updateIcon
# 需要导入模块: from PyQt5.QtWidgets import QGraphicsTextItem [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsTextItem import show [as 别名]
def updateIcon(self, id, uav_state, image_num=0):
if uav_state.get_lon() == 0.0:
#haven't received a Pose message yet
return
if id not in self.__plane_icons:
#make the plane's label first
label = QGraphicsTextItem(str(id), self.__plane_layer)
label.setZValue(2)
label.setDefaultTextColor(Qt.red)
self.__plane_layer.addToGroup(label)
label.show()
self.__plane_labels[id] = label
self.__plane_icons[id] = MapGraphicsIcon(id, label,
self.__plane_layer)
self.__plane_icons[id].centerIconAt(uav_state.get_lon(),
-uav_state.get_lat())
self.__plane_icons[id].textureIcon(self.__plane_icon_pixmaps[image_num])
#plane icons need to be drawn on top of map tiles:
self.__plane_icons[id].setZValue(1)
self.__plane_layer.addToGroup(self.__plane_icons[id])
#key 0 = last update time
self.__plane_icons[id].setData(0, 0)
#refresh:
#HACK: don't know why zooming works to refresh. Couldn't
#get scene.invalidate() nor scene.update() to work
self.onZoom(self.__current_detail_layer)
#end if
now = time.time()
#if we don't have new pose data, then we don't update the plane icon
if (self.__plane_icons[id].data(0) is None
or self.__plane_icons[id].data(0) >= uav_state.get_last_pose_update()):
return
#place icon
self.__plane_icons[id].centerIconAt(uav_state.get_lon(), -uav_state.get_lat())
#give correct heading:
quat = uav_state.get_quat()
heading = acs_math.yaw_from_quat(quat[0], quat[1], quat[2], quat[3])
self.__plane_icons[id].setHeading(heading)
#set last update time
self.__plane_icons[id].setData(0, now)
示例3: Edge
# 需要导入模块: from PyQt5.QtWidgets import QGraphicsTextItem [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsTextItem import show [as 别名]
class Edge(Connection):
''' B-spline/Bezier connection shape '''
def __init__(self, edge, graph):
''' Set generic parameters from Connection class '''
self.text_label = None
super(Edge, self).__init__(edge['source'], edge['target'])
self.edge = edge
self.graph = graph
# Set connection points as not visible, by default
self.bezier_visible = False
# Initialize control point coordinates
self.bezier = [self.mapFromScene(*self.edge['spline'][0])]
# Bezier control points (groups of three points):
assert(len(self.edge['spline']) % 3 == 1)
for i in xrange(1, len(self.edge['spline']), 3):
self.bezier.append([Controlpoint(
self.mapFromScene(*self.edge['spline'][i + j]), self)
for j in range(3)])
# Create connection points at start and end of the edge
self.source_connection = Connectionpoint(
self.start_point or self.bezier[0], self, self.parent)
self.parent.movable_points.append(self.source_connection)
self.end_connection = Connectionpoint(
self.end_point or self.bezier[-1], self, self.child)
self.child.movable_points.append(self.end_connection)
self.reshape()
@property
def start_point(self):
''' Compute connection origin - redefine in subclasses '''
# Start point is optional - graphviz decision
return self.mapFromScene(*self.edge['start']) \
if self.edge.get('start') else None
@property
def end_point(self):
''' Compute connection end point - redefine in subclasses '''
return self.mapFromScene(*self.edge['end']) \
if self.edge.get('end') else None
def bezier_set_visible(self, visible=True):
''' Display or hide the edge control points '''
self.bezier_visible = visible
for group in self.bezier[1:]:
for ctrl_point in group:
if visible:
ctrl_point.show()
else:
ctrl_point.hide()
if visible:
self.end_connection.show()
self.source_connection.show()
else:
self.end_connection.hide()
self.source_connection.hide()
self.update()
def mousePressEvent(self, event):
''' On a mouse click, display the control points '''
self.bezier_set_visible(True)
# pylint: disable=R0914
def reshape(self):
''' Update the shape of the edge (redefined function) '''
path = QPainterPath()
# If there is a starting point, draw a line to the first curve point
if self.start_point:
path.moveTo(self.source_connection.center)
path.lineTo(self.bezier[0])
else:
path.moveTo(self.source_connection.center)
# Loop over the curve points:
for group in self.bezier[1:]:
path.cubicTo(*[point.center for point in group])
# If there is an ending point, draw a line to it
if self.end_point:
path.lineTo(self.end_connection.center)
end_point = path.currentPosition()
arrowhead = self.angle_arrow(path)
path.lineTo(arrowhead[0])
path.moveTo(end_point)
path.lineTo(arrowhead[1])
path.moveTo(end_point)
try:
# Add the transition label, if any (none for the START edge)
font = QFont('arial', pointSize=8)
metrics = QFontMetrics(font)
label = self.edge.get('label', '')
lines = label.split('\n')
width = metrics.width(max(lines)) # longest line
height = metrics.height() * len(lines)
# lp is the position of the center of the text
pos = self.mapFromScene(*self.edge['lp'])
if not self.text_label:
self.text_label = QGraphicsTextItem(
self.edge.get('label', ''), parent=self)
#.........这里部分代码省略.........