本文整理汇总了Python中PySide.QtGui.QPen.setStyle方法的典型用法代码示例。如果您正苦于以下问题:Python QPen.setStyle方法的具体用法?Python QPen.setStyle怎么用?Python QPen.setStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QPen
的用法示例。
在下文中一共展示了QPen.setStyle方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: paint
# 需要导入模块: from PySide.QtGui import QPen [as 别名]
# 或者: from PySide.QtGui.QPen import setStyle [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()
示例2: default_roi_pen
# 需要导入模块: from PySide.QtGui import QPen [as 别名]
# 或者: from PySide.QtGui.QPen import setStyle [as 别名]
def default_roi_pen(dashed=True,color=Qt.green):
pen = QPen()
if dashed:
pen.setStyle(Qt.DashLine)
pen.setBrush(color)
pen.setCapStyle(Qt.RoundCap)
pen.setJoinStyle(Qt.RoundJoin)
return pen
示例3: draw
# 需要导入模块: from PySide.QtGui import QPen [as 别名]
# 或者: from PySide.QtGui.QPen import setStyle [as 别名]
def draw(self, painter, offset, draw_mode=DRAW_MODE_NORMAL):
if draw_mode != Bin.DRAW_MODE_RELEASE:
# Рисуем контур контейнера
pen = QPen()
pen.setStyle(Qt.DashLine)
painter.setPen(pen)
# painter.drawRect(self.origin.x, self.origin.y, self.size.width, self.size.height)
painter.drawRect(offset.x, offset.y, self.size.width, self.size.height)
for image in self.images:
# Rect(rect.origin + self.origin, rect.size, rect.pen).draw(painter=painter)
# image.draw(painter=painter, offset=self.origin)
image.draw(painter=painter, offset=offset)
示例4: paint
# 需要导入模块: from PySide.QtGui import QPen [as 别名]
# 或者: from PySide.QtGui.QPen import setStyle [as 别名]
def paint(self, painter, _, ___):
''' Draw the comment symbol '''
rect = self.boundingRect()
pen = QPen()
pen.setStyle(Qt.DashLine)
pen.setColor(Qt.darkGray)
painter.setPen(pen)
x, y, w, h = rect.x(), rect.y(), rect.width(), rect.height()
if self.on_the_right:
painter.drawLines([QPoint(w, y), QPoint(x, y),
QPoint(x, y), QPoint(x, h),
QPoint(x, h), QPoint(w, h)])
else:
painter.drawLines([QPoint(x, y), QPoint(w, y),
QPoint(w, y), QPoint(w, h),
QPoint(w, h), QPoint(x, h)])
示例5: BaseObject
# 需要导入模块: from PySide.QtGui import QPen [as 别名]
# 或者: from PySide.QtGui.QPen import setStyle [as 别名]
class BaseObject(QGraphicsPathItem):
"""
Subclass of `QGraphicsPathItem`_
TOWRITE
"""
Type = OBJ_TYPE_BASE
def __init__(self, parent=None):
"""
Default class constructor.
:param `parent`: Pointer to a parent widget instance.
:type `parent`: `QGraphicsItem`_
"""
super(BaseObject, self).__init__(parent)
qDebug("BaseObject Constructor()")
self.objPen = QPen() # QPen objPen;
self.lwtPen = QPen() # QPen lwtPen;
self.objLine = QLineF() # QLineF objLine;
self.objRubberMode = int() # int objRubberMode;
self.objRubberPoints = {} # QHash<QString, QPointF> objRubberPoints;
self.objRubberTexts = {} # QHash<QString, QString> objRubberTexts;
self.objID = int() # qint64 objID;
self.objPen.setCapStyle(Qt.RoundCap)
self.objPen.setJoinStyle(Qt.RoundJoin)
self.lwtPen.setCapStyle(Qt.RoundCap)
self.lwtPen.setJoinStyle(Qt.RoundJoin)
self.objID = QDateTime.currentMSecsSinceEpoch()
def __del__(self):
"""Class destructor."""
qDebug("BaseObject Destructor()")
def type(self):
"""
TOWRITE
:return: TOWRITE
:rtype: int
"""
return self.Type
def setObjectColor(self, color):
"""
TOWRITE
:param `color`: TOWRITE
:type `color`: `QColor`_
"""
self.objPen.setColor(color)
self.lwtPen.setColor(color)
def setObjectColorRGB(self, rgb):
"""
TOWRITE
:param `rgb`: TOWRITE
:type `rgb`: `QRgb`_
"""
self.objPen.setColor(QColor(rgb))
self.lwtPen.setColor(QColor(rgb))
def setObjectLineType(self, lineType):
"""
TOWRITE
:param `rgb`: TOWRITE
:type `rgb`: Qt.PenStyle
"""
self.objPen.setStyle(lineType)
self.lwtPen.setStyle(lineType)
def setObjectLineWeight(self, lineWeight):
"""
TOWRITE
:param `lineWeight`: TOWRITE
:type `lineWeight`: qreal
"""
self.objPen.setWidthF(0) # NOTE: The objPen will always be cosmetic
if lineWeight < 0:
if lineWeight == OBJ_LWT_BYLAYER:
self.lwtPen.setWidthF(0.35) # TODO: getLayerLineWeight
elif lineWeight == OBJ_LWT_BYBLOCK:
self.lwtPen.setWidthF(0.35) # TODO: getBlockLineWeight
else:
QMessageBox.warning(0, QObject.tr("Error - Negative Lineweight"),
QObject.tr("Lineweight: %f" % lineWeight))
qDebug("Lineweight cannot be negative! Inverting sign.")
self.lwtPen.setWidthF(-lineWeight)
else:
#.........这里部分代码省略.........
示例6: SelectBox
# 需要导入模块: from PySide.QtGui import QPen [as 别名]
# 或者: from PySide.QtGui.QPen import setStyle [as 别名]
#.........这里部分代码省略.........
self._leftPenColor = QColor()
self._rightPenColor = QColor()
self._alpha = 255 # quint8 #: TODO: what is the initial int?
self._dirBrush = QBrush()
self._leftBrush = QBrush()
self._rightBrush = QBrush()
self._dirPen = QPen()
self._leftPen = QPen()
self._rightPen = QPen()
self._boxDir = False #: TODO: is this initial bool value right?
# Default values
self.setColors(QColor(Qt.darkGreen), QColor(Qt.green), QColor(Qt.darkBlue), QColor(Qt.blue), 32)
def paintEvent(self, event):
"""
Handles the ``paintEvent`` event for :class:`SelectBox`.
:param `event`: A `QPaintEvent`_ to be processed.
"""
painter = QPainter(self)
painter.setPen(self._dirPen)
width, height = self.width(), self.height()
painter.fillRect(0, 0, width - 1, height - 1, self._dirBrush)
painter.drawRect(0, 0, width - 1, height - 1)
def forceRepaint(self):
"""
Force repaint the rubberband.
.. NOTE:: HACK: Take that QRubberBand!
"""
# HACK: Take that QRubberBand!
hack = self.size() # QSize
self.resize(hack + QSize(1, 1))
self.resize(hack)
# Slots ------------------------------------------------------------------
@Slot(int)
def setDirection(self, dir):
"""
TOWRITE
:param `dir`: TOWRITE
:type `dir`: int
"""
if not dir:
self._dirPen = self._leftPen
self._dirBrush = self._leftBrush
else:
self._dirPen = self._rightPen
self._dirBrush = self._rightBrush
self._boxDir = dir
@Slot(QColor, QColor, QColor, QColor, int)
def setColors(self, colorL, fillL, colorR, fillR, newAlpha):
"""
TOWRITE
:param `colorL`: TOWRITE
:type `colorL`: `QColor`_
:param `fillL`: TOWRITE
:type `fillL`: `QColor`_
:param `colorR`: TOWRITE
:type `colorR`: `QColor`_
:param `fillR`: TOWRITE
:type `fillR`: `QColor`_
:param `newAlpha`: TOWRITE
:type `newAlpha`: int
"""
qDebug("SelectBox setColors()")
self._alpha = newAlpha
self._leftPenColor = colorL # TODO: allow customization
self._leftBrushColor = QColor(fillL.red(), fillL.green(), fillL.blue(), self._alpha)
self._rightPenColor = colorR # TODO: allow customization
self._rightBrushColor = QColor(fillR.red(), fillR.green(), fillR.blue(), self._alpha)
self._leftPen.setColor(self._leftPenColor)
self._leftPen.setStyle(Qt.DashLine)
self._leftBrush.setStyle(Qt.SolidPattern)
self._leftBrush.setColor(self._leftBrushColor)
self._rightPen.setColor(self._rightPenColor)
self._rightPen.setStyle(Qt.SolidLine)
self._rightBrush.setStyle(Qt.SolidPattern)
self._rightBrush.setColor(self._rightBrushColor)
if not self._boxDir:
self._dirPen = self._leftPen
self._dirBrush = self._leftBrush
else:
self._dirPen = self._rightPen
self._dirBrush = self._rightBrush
self.forceRepaint()