本文整理汇总了Python中pyqtgraph.functions.mkPen函数的典型用法代码示例。如果您正苦于以下问题:Python mkPen函数的具体用法?Python mkPen怎么用?Python mkPen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mkPen函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, orientation='bottom', allowAdd=True, **kargs):
"""
============= =================================================================================
**Arguments**
orientation Set the orientation of the gradient. Options are: 'left', 'right'
'top', and 'bottom'.
allowAdd Specifies whether ticks can be added to the item by the user.
tickPen Default is white. Specifies the color of the outline of the ticks.
Can be any of the valid arguments for :func:`mkPen <pyqtgraph.mkPen>`
============= =================================================================================
"""
## public
GraphicsWidget.__init__(self)
self.orientation = orientation
self.length = 100
self.tickSize = 15
self.ticks = {}
self.maxDim = 20
self.allowAdd = allowAdd
if 'tickPen' in kargs:
self.tickPen = fn.mkPen(kargs['tickPen'])
else:
self.tickPen = fn.mkPen('w')
self.orientations = {
'left': (90, 1, 1),
'right': (90, 1, 1),
'top': (0, 1, -1),
'bottom': (0, 1, 1)
}
self.setOrientation(orientation)
开发者ID:3rdcycle,项目名称:pyqtgraph,代码行数:32,代码来源:GradientEditorItem.py
示例2: paint
def paint(self, p, *args):
opts = self.opts
if opts.get('antialias', True):
p.setRenderHint(p.Antialiasing)
if opts.get('fillLevel', None) is not None and opts.get('fillBrush', None) is not None:
p.setBrush(fn.mkBrush(opts['fillBrush']))
p.setPen(fn.mkPen(None))
p.drawPolygon(QtGui.QPolygonF([
QtCore.QPointF(2, 18),
QtCore.QPointF(18, 2),
QtCore.QPointF(18, 18)]))
if opts.get('pen', None) is not None:
p.setPen(fn.mkPen(opts['pen']))
p.drawLine(2, 18, 18, 2)
symbol = opts.get('symbol', None)
if symbol is not None:
pen = fn.mkPen(opts.get('symbolPen', None))
brush = fn.mkBrush(opts.get('symbolBrush', None))
size = opts.get('symbolSize', 10)
p.translate(10,10)
path = drawSymbol(p, symbol, size, pen, brush)
开发者ID:corinneteeter,项目名称:multipatch_analysis,代码行数:26,代码来源:throughput.py
示例3: __init__
def __init__(self, node):
#QtGui.QGraphicsItem.__init__(self)
GraphicsObject.__init__(self)
#QObjectWorkaround.__init__(self)
#self.shadow = QtGui.QGraphicsDropShadowEffect()
#self.shadow.setOffset(5,5)
#self.shadow.setBlurRadius(10)
#self.setGraphicsEffect(self.shadow)
self.pen = fn.mkPen(0,0,0)
self.selectPen = fn.mkPen(200,200,200,width=2)
self.brush = fn.mkBrush(200, 200, 200, 150)
self.hoverBrush = fn.mkBrush(200, 200, 200, 200)
self.selectBrush = fn.mkBrush(200, 200, 255, 200)
self.hovered = False
self.node = node
flags = self.ItemIsMovable | self.ItemIsSelectable | self.ItemIsFocusable |self.ItemSendsGeometryChanges
#flags = self.ItemIsFocusable |self.ItemSendsGeometryChanges
self.setFlags(flags)
self.bounds = QtCore.QRectF(0, 0, 100, 100)
self.nameItem = QtGui.QGraphicsTextItem(self.node.name(), self)
self.nameItem.setDefaultTextColor(QtGui.QColor(50, 50, 50))
self.nameItem.moveBy(self.bounds.width()/2. - self.nameItem.boundingRect().width()/2., 0)
self.nameItem.setTextInteractionFlags(QtCore.Qt.TextEditorInteraction)
self.updateTerminals()
#self.setZValue(10)
self.nameItem.focusOutEvent = self.labelFocusOut
self.nameItem.keyPressEvent = self.labelKeyPress
self.menu = None
self.buildMenu()
开发者ID:initbrain,项目名称:intelwiz,代码行数:35,代码来源:Node.py
示例4: buildTorque
def buildTorque(self):
self.pTorque = self.win.addPlot(title="Torque")
self.pTorque.showGrid(x=True, y=True)
self.pTorqueCurves[0] = self.pTorque.plot(pen="r")
self.pTorqueCurves[1] = self.pTorque.plot(pen="b")
self.pTorqueCurves[2] = self.pTorque.plot(pen="g")
self.pTorqueCurves[3] = self.pTorque.plot(pen=mkPen(color="r", style=QtCore.Qt.DotLine))
self.pTorqueCurves[4] = self.pTorque.plot(pen=mkPen(color="b", style=QtCore.Qt.DotLine))
self.pTorqueCurves[5] = self.pTorque.plot(pen=mkPen(color="g", style=QtCore.Qt.DotLine))
开发者ID:nlurkin,项目名称:Drone,代码行数:9,代码来源:DronePlot.py
示例5: buildQuaternion
def buildQuaternion(self):
self.pQuat = self.win.addPlot(title="Quaternion")
self.pQuat.showGrid(x=True, y=True)
self.pQuatCurves[0] = self.pQuat.plot(pen="r")
self.pQuatCurves[1] = self.pQuat.plot(pen="g")
self.pQuatCurves[2] = self.pQuat.plot(pen="b")
self.pQuatCurves[3] = self.pQuat.plot(pen=mkPen(color="r", style=QtCore.Qt.DotLine))
self.pQuatCurves[4] = self.pQuat.plot(pen=mkPen(color="b", style=QtCore.Qt.DotLine))
self.pQuatCurves[5] = self.pQuat.plot(pen=mkPen(color="g", style=QtCore.Qt.DotLine))
开发者ID:nlurkin,项目名称:Drone,代码行数:9,代码来源:DronePlot.py
示例6: paint
def paint(self, p, *args):
if self.isSelected():
p.setPen(fn.mkPen(200, 200, 0, width=3))
else:
if self.hovered:
p.setPen(fn.mkPen(150, 150, 250, width=1))
else:
p.setPen(fn.mkPen(100, 100, 250, width=1))
p.drawLine(0, 0, 0, self.length)
开发者ID:archphy,项目名称:poropy,代码行数:10,代码来源:Terminal.py
示例7: __init__
def __init__(self):
self.penActive = fn.mkPen( 0, 255, 0)
self.penInactive = fn.mkPen(255, 0, 0)
self.penHover = fn.mkPen(255, 255, 0)
self.penActive.setWidth(1)
self.penInactive.setWidth(1)
self.penHover.setWidth(1)
self.setName()
self.isSelected = False
self.menu = None
self.setActive(True)
开发者ID:Frikster,项目名称:ROIviewbox,代码行数:11,代码来源:ROI.py
示例8: paint
def paint(self, p, *args):
if self.isSelected():
p.setPen(fn.mkPen(self.style['selectedColor'], width=self.style['selectedWidth']))
else:
if self.hovered:
p.setPen(fn.mkPen(self.style['hoverColor'], width=self.style['hoverWidth']))
else:
p.setPen(fn.mkPen(self.style['color'], width=self.style['width']))
#p.drawLine(0, 0, 0, self.length)
p.drawPath(self.path)
开发者ID:3rdcycle,项目名称:pyqtgraph,代码行数:12,代码来源:Terminal.py
示例9: addAvgCurve
def addAvgCurve(self, curve):
## Add a single curve into the pool of curves averaged together
## If there are plot parameters, then we need to determine which to average together.
remKeys = []
addKeys = []
if self.ctrl.avgParamList.count() > 0:
### First determine the key of the curve to which this new data should be averaged
for i in range(self.ctrl.avgParamList.count()):
item = self.ctrl.avgParamList.item(i)
if item.checkState() == QtCore.Qt.Checked:
remKeys.append(str(item.text()))
else:
addKeys.append(str(item.text()))
if len(remKeys) < 1: ## In this case, there would be 1 average plot for each data plot; not useful.
return
p = self.itemMeta.get(curve,{}).copy()
for k in p:
if type(k) is tuple:
p['.'.join(k)] = p[k]
del p[k]
for rk in remKeys:
if rk in p:
del p[rk]
for ak in addKeys:
if ak not in p:
p[ak] = None
key = tuple(p.items())
### Create a new curve if needed
if key not in self.avgCurves:
plot = PlotDataItem()
plot.setPen(fn.mkPen([0, 200, 0]))
plot.setShadowPen(fn.mkPen([0, 0, 0, 100], width=3))
plot.setAlpha(1.0, False)
plot.setZValue(100)
self.addItem(plot, skipAverage=True)
self.avgCurves[key] = [0, plot]
self.avgCurves[key][0] += 1
(n, plot) = self.avgCurves[key]
### Average data together
(x, y) = curve.getData()
if plot.yData is not None:
newData = plot.yData * (n-1) / float(n) + y * 1.0 / float(n)
plot.setData(plot.xData, newData)
else:
plot.setData(x, y)
开发者ID:fivejjs,项目名称:pyqtgraph,代码行数:51,代码来源:PlotItem.py
示例10: setSymbolPen
def setSymbolPen(self, *args, **kargs):
pen = fn.mkPen(*args, **kargs)
if self.opts['symbolPen'] == pen:
return
self.opts['symbolPen'] = pen
#self.scatter.setSymbolPen(pen)
self.updateItems()
开发者ID:blink1073,项目名称:pyqtgraph,代码行数:7,代码来源:PlotDataItem.py
示例11: __init__
def __init__(self, *args, **kargs):
"""
Forwards all arguments to :func:`setData <pyqtgraph.PlotCurveItem.setData>`.
Some extra arguments are accepted as well:
============== =======================================================
**Arguments:**
parent The parent GraphicsObject (optional)
clickable If True, the item will emit sigClicked when it is
clicked on. Defaults to False.
============== =======================================================
"""
GraphicsObject.__init__(self, kargs.get('parent', None))
self.clear()
self.path = None
self.fillPath = None
self._boundsCache = [None, None]
## this is disastrous for performance.
#self.setCacheMode(QtGui.QGraphicsItem.DeviceCoordinateCache)
self.metaData = {}
self.opts = {
'pen': fn.mkPen('w'),
'shadowPen': None,
'fillLevel': None,
'brush': None,
'stepMode': False,
'name': None,
'antialias': pg.getConfigOption('antialias'),
}
self.setClickable(kargs.get('clickable', False))
self.setData(*args, **kargs)
开发者ID:cycomanic,项目名称:pyqtgraph,代码行数:34,代码来源:PlotCurveItem.py
示例12: __init__
def __init__(self, **opts):
"""
Arrows can be initialized with any keyword arguments accepted by
the setStyle() method.
"""
QtGui.QGraphicsPathItem.__init__(self, opts.get('parent', None))
if 'size' in opts:
opts['headLen'] = opts['size']
if 'width' in opts:
opts['headWidth'] = opts['width']
defOpts = {
'pxMode': True,
'angle': -150, ## If the angle is 0, the arrow points left
'pos': (0,0),
'headLen': 20,
'tipAngle': 25,
'baseAngle': 0,
'tailLen': None,
'tailWidth': 3,
'pen': (200,200,200),
'brush': (50,50,200),
}
defOpts.update(opts)
self.setStyle(**defOpts)
self.setPen(fn.mkPen(defOpts['pen']))
self.setBrush(fn.mkBrush(defOpts['brush']))
self.rotate(self.opts['angle'])
self.moveBy(*self.opts['pos'])
开发者ID:3rdcycle,项目名称:pyqtgraph,代码行数:31,代码来源:ArrowItem.py
示例13: setShadowPen
def setShadowPen(self, *args, **kargs):
"""Set the shadow pen used to draw behind tyhe primary pen.
This pen must have a larger width than the primary
pen to be visible.
"""
self.opts['shadowPen'] = fn.mkPen(*args, **kargs)
self.update()
开发者ID:archphy,项目名称:poropy,代码行数:7,代码来源:PlotCurveItem.py
示例14: paint
def paint(self, p, *args):
if self.border is None:
return
p.setPen(fn.mkPen(self.border))
for i in self.items:
r = i.mapRectToParent(i.boundingRect())
p.drawRect(r)
开发者ID:emayssat,项目名称:sandbox,代码行数:7,代码来源:GraphicsLayout.py
示例15: addItem
def addItem(self, item, name):
"""
Add a new entry to the legend.
============== ========================================================
**Arguments:**
item A PlotDataItem from which the line and point style
of the item will be determined or an instance of
ItemSample (or a subclass), allowing the item display
to be customized.
title The title to display for this item. Simple HTML allowed.
============== ========================================================
"""
# get item color
pen = fn.mkPen(item.opts['pen'])
color = pen.color()
color_str = color.name()
#create label with same color
label = LabelItem()
label.setAttr('color', str(color_str[1:]))
label.setText(name)
if isinstance(item, ItemSample):
sample = item
else:
sample = ItemSample(item)
self.legendItems.append((sample, label))
self.plotItems.append(item)
self.layout.addItem(sample, self.numItems, 0)
self.layout.addItem(label, self.numItems, 1)
self.numItems += 1
self.updateSize()
开发者ID:kif,项目名称:Py2DeX,代码行数:35,代码来源:ExLegendItem.py
示例16: paintGL
def paintGL(self, p, opt, widget):
p.beginNativePainting()
import OpenGL.GL as gl
## set clipping viewport
view = self.getViewBox()
if view is not None:
rect = view.mapRectToItem(self, view.boundingRect())
#gl.glViewport(int(rect.x()), int(rect.y()), int(rect.width()), int(rect.height()))
#gl.glTranslate(-rect.x(), -rect.y(), 0)
gl.glEnable(gl.GL_STENCIL_TEST)
gl.glColorMask(gl.GL_FALSE, gl.GL_FALSE, gl.GL_FALSE, gl.GL_FALSE) # disable drawing to frame buffer
gl.glDepthMask(gl.GL_FALSE) # disable drawing to depth buffer
gl.glStencilFunc(gl.GL_NEVER, 1, 0xFF)
gl.glStencilOp(gl.GL_REPLACE, gl.GL_KEEP, gl.GL_KEEP)
## draw stencil pattern
gl.glStencilMask(0xFF);
gl.glClear(gl.GL_STENCIL_BUFFER_BIT)
gl.glBegin(gl.GL_TRIANGLES)
gl.glVertex2f(rect.x(), rect.y())
gl.glVertex2f(rect.x()+rect.width(), rect.y())
gl.glVertex2f(rect.x(), rect.y()+rect.height())
gl.glVertex2f(rect.x()+rect.width(), rect.y()+rect.height())
gl.glVertex2f(rect.x()+rect.width(), rect.y())
gl.glVertex2f(rect.x(), rect.y()+rect.height())
gl.glEnd()
gl.glColorMask(gl.GL_TRUE, gl.GL_TRUE, gl.GL_TRUE, gl.GL_TRUE)
gl.glDepthMask(gl.GL_TRUE)
gl.glStencilMask(0x00)
gl.glStencilFunc(gl.GL_EQUAL, 1, 0xFF)
try:
x, y = self.getData()
pos = np.empty((len(x), 2))
pos[:,0] = x
pos[:,1] = y
gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
try:
gl.glVertexPointerf(pos)
pen = fn.mkPen(self.opts['pen'])
color = pen.color()
gl.glColor4f(color.red()/255., color.green()/255., color.blue()/255., color.alpha()/255.)
width = pen.width()
if pen.isCosmetic() and width < 1:
width = 1
gl.glPointSize(width)
gl.glEnable(gl.GL_LINE_SMOOTH)
gl.glEnable(gl.GL_BLEND)
gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
gl.glHint(gl.GL_LINE_SMOOTH_HINT, gl.GL_NICEST);
gl.glDrawArrays(gl.GL_LINE_STRIP, 0, pos.size / pos.shape[-1])
finally:
gl.glDisableClientState(gl.GL_VERTEX_ARRAY)
finally:
p.endNativePainting()
开发者ID:blink1073,项目名称:pyqtgraph,代码行数:59,代码来源:PlotCurveItem.py
示例17: __init__
def __init__(self, pos):
super().__init__()
self.pos = pos
self.pen = fn.mkPen((255, 255, 100), width=1)
self.y1 = 5000
self.picture = None
self._boundingRect = None
self._line = None
开发者ID:gesellkammer,项目名称:sndtrck,代码行数:8,代码来源:interact.py
示例18: __init__
def __init__(self, size, width=5, color=(100, 100, 255)):
UIGraphicsItem.__init__(self)
self.setAcceptedMouseButtons(QtCore.Qt.NoButton)
self.brush = fn.mkBrush(color)
self.pen = fn.mkPen((0,0,0))
self._width = width
self.size = size
开发者ID:cycomanic,项目名称:pyqtgraph,代码行数:8,代码来源:ScaleBar.py
示例19: buildAtlas
def buildAtlas(self):
# get rendered array for all symbols, keep track of avg/max width
rendered = {}
avgWidth = 0.0
maxWidth = 0
images = []
for key, coords in self.symbolMap.items():
if len(coords) == 0:
pen = fn.mkPen(color=key[2], width=key[3], style=key[4])
brush = fn.mkBrush(color=key[5])
img = renderSymbol(key[0], key[1], pen, brush)
images.append(img) ## we only need this to prevent the images being garbage collected immediately
arr = fn.imageToArray(img, copy=False, transpose=False)
else:
(x,y,w,h) = self.symbolMap[key]
arr = self.atlasData[x:x+w, y:y+w]
rendered[key] = arr
w = arr.shape[0]
avgWidth += w
maxWidth = max(maxWidth, w)
nSymbols = len(rendered)
if nSymbols > 0:
avgWidth /= nSymbols
width = max(maxWidth, avgWidth * (nSymbols**0.5))
else:
avgWidth = 0
width = 0
# sort symbols by height
symbols = sorted(rendered.keys(), key=lambda x: rendered[x].shape[1], reverse=True)
self.atlasRows = []
x = width
y = 0
rowheight = 0
for key in symbols:
arr = rendered[key]
w,h = arr.shape[:2]
if x+w > width:
y += rowheight
x = 0
rowheight = h
self.atlasRows.append([y, rowheight, 0])
self.symbolMap[key][:] = x, y, w, h
x += w
self.atlasRows[-1][2] = x
height = y + rowheight
self.atlasData = np.zeros((width, height, 4), dtype=np.ubyte)
for key in symbols:
x, y, w, h = self.symbolMap[key]
self.atlasData[x:x+w, y:y+h] = rendered[key]
self.atlas = None
self.atlasValid = True
开发者ID:fivejjs,项目名称:pyqtgraph,代码行数:56,代码来源:ScatterPlotItem.py
示例20: paintEvent
def paintEvent(self, ev):
QtGui.QAbstractSpinBox.paintEvent(self, ev)
## draw red border if text is invalid
if not self.textValid:
p = QtGui.QPainter(self)
p.setRenderHint(p.Antialiasing)
p.setPen(fn.mkPen((200,50,50), width=2))
p.drawRoundedRect(self.rect().adjusted(2, 2, -2, -2), 4, 4)
p.end()
开发者ID:a-stark,项目名称:qudi,代码行数:10,代码来源:SpinBox.py
注:本文中的pyqtgraph.functions.mkPen函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论