本文整理汇总了Python中PySide.QtGui.QPen.setWidth方法的典型用法代码示例。如果您正苦于以下问题:Python QPen.setWidth方法的具体用法?Python QPen.setWidth怎么用?Python QPen.setWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QPen
的用法示例。
在下文中一共展示了QPen.setWidth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init
# 需要导入模块: from PySide.QtGui import QPen [as 别名]
# 或者: from PySide.QtGui.QPen import setWidth [as 别名]
def init(self, parent):
'''
'''
if self.control is None:
self.control = qtLED()
scene = QGraphicsScene()
# self.control.setStyleSheet("qtLED { border-style: none; }");
# self.control.setAutoFillBackground(True)
# system background color
scene.setBackgroundBrush(QBrush(QColor(237, 237, 237)))
self.control.setStyleSheet("border: 0px")
self.control.setMaximumWidth(35)
self.control.setMaximumHeight(35)
x, y = 10, 10
rad = 20
cx = x + rad / 1.75
cy = y + rad / 1.75
brush = self.get_color(self.value.state, cx, cy, rad / 2)
pen = QPen()
pen.setWidth(0)
self.led = scene.addEllipse(x, y, rad, rad,
pen=pen,
brush=brush
)
self.control.setScene(scene)
self.value.on_trait_change(self.update_object, 'state')
示例2: paintEvent
# 需要导入模块: from PySide.QtGui import QPen [as 别名]
# 或者: from PySide.QtGui.QPen import setWidth [as 别名]
def paintEvent(self, ev):
if self.isEnabled():
color = self.color
colorBorder = [0.4, 0.4, 0.4]
else:
color = [0.8, 0.8, 0.8]
colorBorder = [0.7, 0.7, 0.7]
painter = QPainter(self)
painter.setRenderHint(QPainter.Antialiasing)
painter.setRenderHint(QPainter.HighQualityAntialiasing)
if self.isChecked():
pen = QPen(QColor.fromRgbF(0.2, 0.2, 0.2))
pen.setWidth(2.0)
else:
pen = QPen(QColor.fromRgbF(colorBorder[0], colorBorder[1], colorBorder[2]))
pen.setWidth(1.0)
size = self.size()
sizeCircle = 12.0
x = size.width() / 2.0 - (sizeCircle / 2.0)
y = size.height() / 2.0 - (sizeCircle / 2.0)
rect = QRectF(x, y, sizeCircle, sizeCircle)
painter.setPen(pen)
painter.setBrush(QColor.fromRgbF(color[0], color[1], color[2]))
painter.drawEllipse(rect)
示例3: p
# 需要导入模块: from PySide.QtGui import QPen [as 别名]
# 或者: from PySide.QtGui.QPen import setWidth [as 别名]
def p(painter, color):
device = painter.device()
width, height = device.width(), device.height()
painter.setRenderHint(QPainter.Antialiasing)
pen = QPen()
pen.setWidth(thickness)
if random:
pen.setBrush(noise_brush)
painter.setPen(pen)
painter.setOpacity(opacity/100)
def getpoints(x, y):
if angle in [0, 180]:
return (0, y), (width, y)
if angle in [90, 270]:
return (x, 0), (x, height)
derp = max(height, width)
deg = math.radians(angle)
p1 = (x - derp*math.cos(deg), y + derp * math.sin(deg))
p2 = (x+derp*math.cos(deg), y - derp * math.sin(deg))
return p1, p2
for pos in range(spacing+thickness, max(height, width), spacing+thickness):
x = pos if angle < 90 else width-pos
y = pos
(x1, y1), (x2, y2) = getpoints(x, y)
painter.drawLine(x1, y1, x2, y2)
return
示例4: paintEvent
# 需要导入模块: from PySide.QtGui import QPen [as 别名]
# 或者: from PySide.QtGui.QPen import setWidth [as 别名]
def paintEvent(self, pe):
# make an arrow polygon right in the middle
painter = QPainter(self)
painter.setPen(Qt.NoPen)
# draw the background transparent rect
painter.save()
painter.setOpacity(self.BACKGROUND_OPACITY)
# get the rectangle coordinates it should extend over the whole width with only a portion at the center
painter.setBrush(Qt.black)
empty_space_percent = 1 - self.BACKROUND_HEIGHT_PERCENT
rect_top = empty_space_percent / 2 * self.height()
rect_height = self.BACKROUND_HEIGHT_PERCENT * self.height()
painter.drawRect(0, rect_top, self.width(), rect_height)
painter.restore()
painter.setRenderHint(QPainter.Antialiasing)
pen = QPen()
pen.setWidth(self.ARROW_LINE_WIDTH)
pen.setCapStyle(Qt.RoundCap)
if self._mouse_inside:
pen.setColor(self._hover_color)
else:
pen.setColor(self._normal_color)
# get the arrow coords
painter.setPen(pen)
self_center = QPointF(self.width() / 2, self.height() / 2) # use this as the arrow tip for now
if self._direction == self.LEFT:
h_shift = self._arrow_width
elif self._direction == self.RIGHT:
h_shift = - self._arrow_width
v_shift = self._arrow_height / 2
top_point = self_center + QPointF(h_shift, - v_shift)
bottom_point = self_center + QPointF(h_shift, v_shift)
painter.drawLine(top_point, self_center)
painter.drawLine(self_center, bottom_point)
示例5: paintEvent
# 需要导入模块: from PySide.QtGui import QPen [as 别名]
# 或者: from PySide.QtGui.QPen import setWidth [as 别名]
def paintEvent(self, pe):
painter = QPainter(self)
painter.save()
gradient = QLinearGradient()
gradient.setStart(self._grad_start)
gradient.setFinalStop(self._grad_end)
gradient.setColorAt(0, QColor(230, 230, 230))
gradient.setColorAt(1, QColor(247, 247, 247))
brush = QBrush(gradient)
painter.setBrush(brush)
pen = QPen(Qt.black)
pen.setWidth(1)
painter.setPen(pen)
painter.drawPath(self._painter_path)
painter.restore()
font = QFont()
font.setFamily("Tahoma")
font.setPixelSize(11)
font.setBold(True)
pen = QPen(Qt.darkGray)
painter.setPen(pen)
painter.setFont(font)
self_rect = QRect(self.rect())
self_rect.moveTo(self._hor_margin, self._ver_margin // 2)
painter.drawText(self_rect, Qt.AlignLeft, self._text)
示例6: paintEvent
# 需要导入模块: from PySide.QtGui import QPen [as 别名]
# 或者: from PySide.QtGui.QPen import setWidth [as 别名]
def paintEvent(self, pe):
if not self._hover_rect:
super(TrackerWebView, self).paintEvent(pe)
else:
super(TrackerWebView, self).paintEvent(pe)
hover_rect = self._hover_rect
self._fixRectForScroll(hover_rect)
painter = QPainter(self)
painter.save()
pen = QPen(Qt.red)
pen.setWidth(2)
painter.setPen(pen)
painter.drawRect(hover_rect)
painter.restore()
# draw green rects around the similar elements
pen = QPen()
pen.setWidth(2)
for field_info in self._fields_info:
painter.save()
web_elements = field_info.web_elements
color = field_info.color
pen.setColor(color)
painter.setPen(pen)
for elem in web_elements:
elem_rect = elem.absoluteGeometry()
painter.drawRoundedRect(self._fixRectForScroll(elem_rect), 2, 2)
painter.restore()
示例7: paint
# 需要导入模块: from PySide.QtGui import QPen [as 别名]
# 或者: from PySide.QtGui.QPen import setWidth [as 别名]
def paint(self, canvas, is_secondary_color=False, additional_flag=False):
pen = QPen()
if is_secondary_color:
pen.setColor(self.data_singleton.secondary_color)
else:
pen.setColor(self.data_singleton.primary_color)
painter = QPainter(canvas.image)
painter.setRenderHint(QPainter.Antialiasing)
pen.setWidth(self.data_singleton.pen_size)
pen.setStyle(Qt.SolidLine)
pen.setCapStyle(Qt.RoundCap)
pen.setJoinStyle(Qt.RoundJoin)
painter.setPen(pen)
if is_secondary_color:
painter.setBrush(self.data_singleton.primary_color)
else:
painter.setBrush(self.data_singleton.secondary_color)
if self._start_point != self._end_point:
painter.drawRect(QRect(self._start_point, self._end_point))
painter.end()
canvas.edited = True
canvas.update()
示例8: setChosen
# 需要导入模块: from PySide.QtGui import QPen [as 别名]
# 或者: from PySide.QtGui.QPen import setWidth [as 别名]
def setChosen(self, ch):
self.chosen = ch
if ch:
redPen = QPen(Qt.red)
redPen.setWidth(2)
self.setPen(redPen)
else:
self.setPen(QPen())
示例9: drawPolyline
# 需要导入模块: from PySide.QtGui import QPen [as 别名]
# 或者: from PySide.QtGui.QPen import setWidth [as 别名]
def drawPolyline(self):
path = [mark.coordinate() for mark in self.markerObjects]
pen = QPen(Qt.white)
pen.setWidth(2)
pen.setCosmetic(True)
polyline = QGeoMapPolylineObject()
polyline.setPen(pen)
polyline.setPath(path)
self.mapWidget.addMapObject(polyline)
示例10: routeFinished
# 需要导入模块: from PySide.QtGui import QPen [as 别名]
# 或者: from PySide.QtGui.QPen import setWidth [as 别名]
def routeFinished(self):
if not self.routeReply.routes():
return
route = QGeoMapRouteObject(self.routeReply.routes()[0])
routeColor = QColor(Qt.blue)
routeColor.setAlpha(127)
pen = QPen(routeColor)
pen.setWidth(7)
pen.setCosmetic(True)
pen.setCapStyle(Qt.RoundCap)
route.setPen(pen)
self.mapWidget.addMapObject(route)
示例11: drawPolygon
# 需要导入模块: from PySide.QtGui import QPen [as 别名]
# 或者: from PySide.QtGui.QPen import setWidth [as 别名]
def drawPolygon(self):
path = [mark.coordinate() for mark in self.markerObjects]
pen = QPen(Qt.white)
pen.setWidth(2)
pen.setCosmetic(True)
polygon = QGeoMapPolygonObject()
polygon.setPen(pen)
fill = QColor(Qt.black)
fill.setAlpha(65)
polygon.setBrush(QBrush(fill))
polygon.setPath(path)
self.mapWidget.addMapObject(polygon)
示例12: drawRect
# 需要导入模块: from PySide.QtGui import QPen [as 别名]
# 或者: from PySide.QtGui.QPen import setWidth [as 别名]
def drawRect(self):
if len(self.markerObjects) < 2:
return
p1, p2 = self.markerObjects[:2]
pen = QPen(Qt.white)
pen.setWidth(2)
pen.setCosmetic(True)
fill = QColor(Qt.black)
fill.setAlpha(65)
rectangle = QGeoMapRectangleObject(p1.coordinate(), p2.coordinate())
rectangle.setPen(pen)
rectangle.setBrush(QBrush(fill))
self.mapWidget.addMapObject(rectangle)
示例13: drawWidget
# 需要导入模块: from PySide.QtGui import QPen [as 别名]
# 或者: from PySide.QtGui.QPen import setWidth [as 别名]
def drawWidget(self, qp):
size = self.size()
radx = size.width()
rady = size.height()
dot = min(radx, rady) / 2
pen = QPen()
pen.setWidth(dot)
# pen.setStyle(Qt.SolidLine)
pen.setBrush(self.color)
# pen.setCapStyle(Qt.RoundCap)
# pen.setJoinStyle(Qt.RoundJoin)
qp.setPen(pen)
qp.drawLine(dot, dot, dot, dot)
示例14: draw_uvs
# 需要导入模块: from PySide.QtGui import QPen [as 别名]
# 或者: from PySide.QtGui.QPen import setWidth [as 别名]
def draw_uvs(self):
self.img = QPixmap(QSize(self.w, self.h))
pen = QPen()
pen.setWidth(int(self.pen_w.text()))
pen.setBrush(QBrush(Qt.white))
pen.setColor(QColor('white'))
painter = QPainter()
painter.begin(self.img)
painter.setPen(pen)
coords = self.get_coords()
for face in coords:
for n in xrange(len(face) - 1):
print face[n][0], face[n][1], face[n + 1][0], face[n + 1][1]
painter.drawLine(face[n][0], face[n][1], face[n + 1][0], face[n + 1][1])
painter.end()
self.view.scene().addPixmap(self.img)
示例15: setRoute
# 需要导入模块: from PySide.QtGui import QPen [as 别名]
# 或者: from PySide.QtGui.QPen import setWidth [as 别名]
def setRoute(self, route):
t = route.strip("{}")
cs = t.split(";")
path = list()
for c in cs:
c = c.strip("()")
latitude = c[0:c.rfind(",")]
longitude = c[c.rfind(",")+1:len(c)]
path.append(QGeoCoordinate(float(latitude), float(longitude)))
self.route = QGeoRoute()
self.route.setPath(path)
self.route_object = QGeoMapPolylineObject()
self.route_object.setPath(path)
pen = QPen(QtCore.Qt.red)
pen.setWidth(5)
self.route_object.setPen(pen)
self.route_object.setZValue(1)
self.addMapObject(self.route_object)