本文整理汇总了Python中PySide.QtGui.QPen.color方法的典型用法代码示例。如果您正苦于以下问题:Python QPen.color方法的具体用法?Python QPen.color怎么用?Python QPen.color使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QPen
的用法示例。
在下文中一共展示了QPen.color方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: BaseObject
# 需要导入模块: from PySide.QtGui import QPen [as 别名]
# 或者: from PySide.QtGui.QPen import color [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:
#.........这里部分代码省略.........
示例2: loadFile
# 需要导入模块: from PySide.QtGui import QPen [as 别名]
# 或者: from PySide.QtGui.QPen import color [as 别名]
def loadFile(self, fileName):
"""
TOWRITE
:param `fileName`: TOWRITE
:type `fileName`: QString
:rtype: bool
"""
qDebug("MdiWindow loadFile()")
tmpColor = self.getCurrentColor() # QRgb
file = QFile(fileName)
if not file.open(QFile.ReadOnly | QFile.Text):
QMessageBox.warning(
self,
self.tr("Error reading file"),
self.tr("Cannot read file %s:\n%s." % (fileName, file.errorString()))
)
return False
QApplication.setOverrideCursor(Qt.WaitCursor)
ext = self.fileExtension(fileName) # QString
qDebug("ext: %s" % qPrintable(ext))
# Read
p = embPattern_create() # EmbPattern*
if not p:
print("Could not allocate memory for embroidery pattern\n")
exit(1)
readSuccessful = 0 # int
## QString readError
reader = embReaderWriter_getByFileName(qPrintable(fileName)) # EmbReaderWriter*
if not reader:
readSuccessful = 0
readError = "Unsupported read file type: " + fileName
qDebug("Unsupported read file type: %s\n" % qPrintable(fileName))
else:
readSuccessful = reader.reader(p, qPrintable(fileName))
if not readSuccessful:
readError = "Reading file was unsuccessful: " + fileName
qDebug("Reading file was unsuccessful: %s\n" % qPrintable(fileName))
## free(reader) #TODO/REMOVE# not needed in python
if not readSuccessful:
QMessageBox.warning(self, self.tr("Error reading pattern"), self.tr(qPrintable(readError)))
if readSuccessful:
embPattern_moveStitchListToPolylines(p) # TODO: Test more
stitchCount = embStitchList_count(p.stitchList) # int
path = QPainterPath()
if p.circleObjList:
curCircleObj = p.circleObjList # EmbCircleObjectList*
while curCircleObj:
c = curCircleObj.circleObj.circle # EmbCircle
thisColor = curCircleObj.circleObj.color # EmbColor
self.setCurrentColor(qRgb(thisColor.r, thisColor.g, thisColor.b))
# NOTE: With natives, the Y+ is up and libembroidery Y+ is up, so inverting the Y is NOT needed.
self.mainWin.nativeAddCircle(embCircle_centerX(c), embCircle_centerY(c), embCircle_radius(c), False, OBJ_RUBBER_OFF) # TODO: fill
curCircleObj = curCircleObj.next
if p.ellipseObjList:
curEllipseObj = p.ellipseObjList # EmbEllipseObjectList*
while curEllipseObj:
e = curEllipseObj.ellipseObj.ellipse # EmbEllipse
thisColor = curEllipseObj.ellipseObj.color # EmbColor
self.setCurrentColor(qRgb(thisColor.r, thisColor.g, thisColor.b))
# NOTE: With natives, the Y+ is up and libembroidery Y+ is up, so inverting the Y is NOT needed.
self.mainWin.nativeAddEllipse(embEllipse_centerX(e), embEllipse_centerY(e), embEllipse_width(e), embEllipse_height(e), 0, False, OBJ_RUBBER_OFF) # TODO: rotation and fill
curEllipseObj = curEllipseObj.next
if p.lineObjList:
curLineObj = p.lineObjList # EmbLineObjectList*
while curLineObj:
li = curLineObj.lineObj.line # EmbLine
thisColor = curLineObj.lineObj.color # EmbColor
self.setCurrentColor(qRgb(thisColor.r, thisColor.g, thisColor.b))
# NOTE: With natives, the Y+ is up and libembroidery Y+ is up, so inverting the Y is NOT needed.
self.mainWin.nativeAddLine(embLine_x1(li), embLine_y1(li), embLine_x2(li), embLine_y2(li), 0, OBJ_RUBBER_OFF) # TODO: rotation
curLineObj = curLineObj.next
if p.pathObjList:
# TODO: This is unfinished. It needs more work
curPathObjList = p.pathObjList # EmbPathObjectList*
while curPathObjList:
pathPath = QPainterPath()
curPointList = curPathObjList.pathObj.pointList # EmbPointList*
thisColor = curPathObjList.pathObj.color # EmbColor
if curPointList:
pp = curPointList.point # EmbPoint
pathPath.moveTo(embPoint_x(pp), -embPoint_y(pp)) # NOTE: Qt Y+ is down and libembroidery Y+ is up, so inverting the Y is needed.
curPointList = curPointList.next
while curPointList:
pp = curPointList.point # EmbPoint
pathPath.lineTo(embPoint_x(pp), -embPoint_y(pp)) # NOTE: Qt Y+ is down and libembroidery Y+ is up, so inverting the Y is needed.
curPointList = curPointList.next
#.........这里部分代码省略.........