本文整理汇总了Python中PySide.QtGui.QPen.setWidthF方法的典型用法代码示例。如果您正苦于以下问题:Python QPen.setWidthF方法的具体用法?Python QPen.setWidthF怎么用?Python QPen.setWidthF使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QPen
的用法示例。
在下文中一共展示了QPen.setWidthF方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: selectionLayer
# 需要导入模块: from PySide.QtGui import QPen [as 别名]
# 或者: from PySide.QtGui.QPen import setWidthF [as 别名]
class selectionLayer(layer):
def __init__(self, size, dynamic, controller, prototypeLine, opaqueBack = False):
layer.__init__(self,size,dynamic)
self.controller = controller
self.points = set()
if opaqueBack:
self.backgroundColor = Qt.white
else:
self.backgroundColor = Qt.transparent
lineColor = QColor()
lineColor.setNamedColor(prototypeLine.getAttribute('stroke'))
lineColor.setAlphaF(float(prototypeLine.getAttribute('stroke-opacity')))
self.pen = QPen(lineColor)
self.pen.setWidthF(prototypeLine.getAttribute('stroke-width'))
def handleFrame(self, event, signals):
return signals
def refreshLines(self, points):
self.points = points
self.setDirty()
def draw(self,painter):
if len(self.points) >= self.controller.app.resolution_threshold:
return
pointList = list(self.points)
self.image.fill(self.backgroundColor)
painter.setPen(self.pen)
painter.setRenderHint(QPainter.Antialiasing)
lastA = self.controller.axisOrder[0]
lastValues = self.controller.vData.getData(pointList,lastA)
lastX = self.controller.axes[lastA].visAxis.axisLine.left()
for a in self.controller.axisOrder[1:]:
if not self.controller.axes[a].visible:
continue
values = self.controller.vData.getData(pointList,a)
x = self.controller.axes[a].visAxis.axisLine.left()
for y0,y1 in zip(lastValues,values):
y0 = self.controller.axes[lastA].dataToScreen(y0)
y1 = self.controller.axes[a].dataToScreen(y1)
if len(y0) > len(y1):
if len(y1) > 1:
raise Exception("Mismatched number of values between attributes: %s %s" % (y0,y1))
else:
for y00 in y0:
painter.drawLine(lastX,y00,x,y1[0])
elif len(y1) > len(y0):
if len(y0) > 1:
raise Exception("Mismatched number of values between attributes: %s %s" % (y0,y1))
else:
for y11 in y1:
painter.drawLine(lastX,y0[0],x,y11)
else:
for i,y00 in enumerate(y0):
painter.drawLine(lastX,y00,x,y1[i])
lastA = a
lastValues = values
lastX = x
示例2: _cutPen
# 需要导入模块: from PySide.QtGui import QPen [as 别名]
# 或者: from PySide.QtGui.QPen import setWidthF [as 别名]
def _cutPen(self):
if self.edit_mode:
pen = QPen()
pen.setWidthF(0.03)
return pen
else:
pen = QPen(Qt.gray)
pen.setWidthF(0.02)
return pen
示例3: realRender
# 需要导入模块: from PySide.QtGui import QPen [as 别名]
# 或者: from PySide.QtGui.QPen import setWidthF [as 别名]
def realRender(self, painter, renderPath): # TODO/PORT: Still needs work.
"""
TOWRITE
:param `painter`: TOWRITE
:type `painter`: `QPainter`_
:param `renderPath`: TOWRITE
:type `renderPath`: `QPainterPath`_
"""
color1 = self.objectColor() #QColor # lighter color
color2 = color1.darker(150) #QColor # darker color
# If we have a dark color, lighten it
darkness = color1.lightness() #int
threshold = 32 #int #TODO: This number may need adjusted or maybe just add it to settings.
if darkness < threshold:
color2 = color1
if not darkness:
color1 = QColor(threshold, threshold, threshold) # lighter() does not affect pure black
else :
color1 = color2.lighter(100 + threshold)
count = renderPath.elementCount() # int
for i in range(0, count - 1): # for(int i = 0; i < count-1; ++i);
elem = renderPath.elementAt(i) # QPainterPath::Element
next = renderPath.elementAt(i + 1) # QPainterPath::Element
if next.isMoveTo():
continue
elemPath = QPainterPath()
elemPath.moveTo(elem.x, elem.y)
elemPath.lineTo(next.x, next.y)
renderPen = QPen(QColor(0, 0, 0, 0))
renderPen.setWidthF(0)
painter.setPen(renderPen)
stroker = QPainterPathStroker()
stroker.setWidth(0.35)
stroker.setCapStyle(Qt.RoundCap)
stroker.setJoinStyle(Qt.RoundJoin)
realPath = stroker.createStroke(elemPath) # QPainterPath
painter.drawPath(realPath)
grad = QLinearGradient(elemPath.pointAtPercent(0.5), elemPath.pointAtPercent(0.0))
grad.setColorAt(0, color1)
grad.setColorAt(1, color2)
grad.setSpread(QGradient.ReflectSpread)
painter.fillPath(realPath, QBrush(grad))
示例4: BaseObject
# 需要导入模块: from PySide.QtGui import QPen [as 别名]
# 或者: from PySide.QtGui.QPen import setWidthF [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:
#.........这里部分代码省略.........
示例5: paintEvent
# 需要导入模块: from PySide.QtGui import QPen [as 别名]
# 或者: from PySide.QtGui.QPen import setWidthF [as 别名]
def paintEvent( self, event ):
painter = QPainter()
painter.begin(self)
painter.setRenderHint(painter.Antialiasing)
font = painter.font()
font.setBold(True)
painter.setFont(font)
x = self.rect().x()
y = self.rect().y()
w = self.rect().width() - 1
h = self.rect().height() - 1
r = 8
# draw a rounded style
if self._rolloutStyle == 2:
# draw the text
painter.drawText(x + 33, y + 3, w, 16, Qt.AlignLeft | Qt.AlignTop, self.title())
# draw the triangle
self.__drawTriangle(painter, x, y)
# draw the borders
pen = QPen(self.palette().color(QPalette.Light))
pen.setWidthF(0.6)
painter.setPen(pen)
painter.drawRoundedRect(x + 1, y + 1, w - 1, h - 1, r, r)
pen.setColor(self.palette().color(QPalette.Shadow))
painter.setPen(pen)
painter.drawRoundedRect(x, y, w - 1, h - 1, r, r)
# draw a square style
if self._rolloutStyle == 3:
# draw the text
painter.drawText(x + 33, y + 3, w, 16, Qt.AlignLeft | Qt.AlignTop, self.title())
self.__drawTriangle(painter, x, y)
# draw the borders
pen = QPen(self.palette().color(QPalette.Light))
pen.setWidthF(0.6)
painter.setPen(pen)
painter.drawRect(x + 1, y + 1, w - 1, h - 1)
pen.setColor(self.palette().color(QPalette.Shadow))
painter.setPen(pen)
painter.drawRect(x, y, w - 1, h - 1)
# draw a Maya style
if self._rolloutStyle == 4:
# draw the text
painter.drawText(x + 33, y + 3, w, 16, Qt.AlignLeft | Qt.AlignTop, self.title())
painter.setRenderHint(QPainter.Antialiasing, False)
self.__drawTriangle(painter, x, y)
# draw the borders - top
headerHeight = 20
headerRect = QRect(x + 1, y + 1, w - 1, headerHeight)
headerRectShadow = QRect(x - 1, y - 1, w + 1, headerHeight + 2)
# Highlight
pen = QPen(self.palette().color(QPalette.Light))
pen.setWidthF(0.4)
painter.setPen(pen)
painter.drawRect(headerRect)
painter.fillRect(headerRect, QColor(255, 255, 255, 18))
# Shadow
pen.setColor(self.palette().color(QPalette.Dark))
painter.setPen(pen)
painter.drawRect(headerRectShadow)
if not self.isCollapsed():
# draw the lover border
pen = QPen(self.palette().color(QPalette.Dark))
pen.setWidthF(0.8)
painter.setPen(pen)
offSet = headerHeight + 3
bodyRect = QRect(x, y + offSet, w, h - offSet)
bodyRectShadow = QRect(x + 1, y + offSet, w + 1, h - offSet + 1)
painter.drawRect(bodyRect)
pen.setColor(self.palette().color(QPalette.Light))
pen.setWidthF(0.4)
painter.setPen(pen)
painter.drawRect(bodyRectShadow)
# draw a boxed style
elif self._rolloutStyle == 1:
#.........这里部分代码省略.........
示例6: loadFile
# 需要导入模块: from PySide.QtGui import QPen [as 别名]
# 或者: from PySide.QtGui.QPen import setWidthF [as 别名]
#.........这里部分代码省略.........
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
loadPen = QPen(qRgb(thisColor.r, thisColor.g, thisColor.b))
loadPen.setWidthF(0.35)
loadPen.setCapStyle(Qt.RoundCap)
loadPen.setJoinStyle(Qt.RoundJoin)
obj = PathObject(0, 0, pathPath, loadPen.color().rgb()) # PathObject*
obj.setObjectRubberMode(OBJ_RUBBER_OFF)
self.gscene.addItem(obj)
curPathObjList = curPathObjList.next
if p.pointObjList:
curPointObj = p.pointObjList # EmbPointObjectList*
while curPointObj:
po = curPointObj.pointObj.point # EmbPoint
thisColor = curPointObj.pointObj.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.nativeAddPoint(embPoint_x(po), embPoint_y(po))
curPointObj = curPointObj.next
if p.polygonObjList:
curPolygonObjList = p.polygonObjList # EmbPolygonObjectList*
while curPolygonObjList:
polygonPath = QPainterPath()
firstPoint = False # bool
startX = 0; startY = 0 # qreal
x = 0; y = 0 # qreal
curPointList = curPolygonObjList.polygonObj.pointList # EmbPointList*
thisColor = curPolygonObjList.polygonObj.color # EmbColor
self.setCurrentColor(qRgb(thisColor.r, thisColor.g, thisColor.b))
while curPointList:
pp = curPointList.point # EmbPoint
x = embPoint_x(pp)
示例7: QColor
# 需要导入模块: from PySide.QtGui import QPen [as 别名]
# 或者: from PySide.QtGui.QPen import setWidthF [as 别名]
from PySide.QtGui import QColor, QBrush, QPen
from PySide.QtCore import Qt
print "Initializing Color"
colorHexLine = QColor(Qt.green)
colorHexBrush = QColor(192,255,192)
colorHexRoute = QColor(255,192,0)
colorHexRoute.setAlpha(128)
colorHexRouteSel = QColor(192,128,0)
colorHexRouteSel.setAlpha(128)
penLine = QPen(colorHexLine)
penLine.setWidthF(2.0)
penRoute = QPen(colorHexRoute)
penRoute.setWidthF(12.0)
penRouteSel = QPen(colorHexRouteSel)
penRouteSel.setWidthF(12.0)
brushHex = QBrush(colorHexBrush)