本文整理汇总了Python中pyqtgraph.functions.mkBrush函数的典型用法代码示例。如果您正苦于以下问题:Python mkBrush函数的具体用法?Python mkBrush怎么用?Python mkBrush使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mkBrush函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __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()
示例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)
示例3: process
def process(self, In):
kwargs = self.CW().prepareInputArguments()
if kwargs['closed']:
self.graphicsItem().setBrush(fn.mkBrush(self.closed_color))
return {'Out': None}
else:
self.graphicsItem().setBrush(fn.mkBrush(self.opened_color))
return {'Out': In}
示例4: paintEvent
def paintEvent(self, ev):
QtGui.QPushButton.paintEvent(self, ev)
p = QtGui.QPainter(self)
rect = self.rect().adjusted(6, 6, -6, -6)
## draw white base, then texture for indicating transparency, then actual color
p.setBrush(functions.mkBrush('w'))
p.drawRect(rect)
p.setBrush(QtGui.QBrush(QtCore.Qt.DiagCrossPattern))
p.drawRect(rect)
p.setBrush(functions.mkBrush(self._color))
p.drawRect(rect)
p.end()
示例5: __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'])
示例6: setSymbolBrush
def setSymbolBrush(self, *args, **kargs):
brush = fn.mkBrush(*args, **kargs)
if self.opts['symbolBrush'] == brush:
return
self.opts['symbolBrush'] = brush
#self.scatter.setSymbolBrush(brush)
self.updateItems()
示例7: updateBackground
def updateBackground(self):
bg = self.state['background']
if bg is None:
self.background.hide()
else:
self.background.show()
self.background.setBrush(fn.mkBrush(bg))
示例8: hoverEvent
def hoverEvent(self, ev):
if not ev.isExit() and ev.acceptDrags(QtCore.Qt.LeftButton):
ev.acceptClicks(QtCore.Qt.LeftButton) ## we don't use the click, but we also don't want anyone else to use it.
self.box.setBrush(fn.mkBrush('w'))
else:
self.box.setBrush(self.brush)
self.update()
示例9: __init__
def __init__(self, parent=None, useOpenGL=None, background='k'):
"""Re-implementation of QGraphicsView that removes scrollbars and allows unambiguous control of the
viewed coordinate range. Also automatically creates a QGraphicsScene and a central QGraphicsWidget
that is automatically scaled to the full view geometry.
By default, the view coordinate system matches the widget's pixel coordinates and
automatically updates when the view is resized. This can be overridden by setting
autoPixelRange=False. The exact visible range can be set with setRange().
The view can be panned using the middle mouse button and scaled using the right mouse button if
enabled via enableMouse() (but ordinarily, we use ViewBox for this functionality)."""
self.closed = False
QtGui.QGraphicsView.__init__(self, parent)
if useOpenGL is None:
useOpenGL = pyqtgraph.getConfigOption('useOpenGL')
self.useOpenGL(useOpenGL)
self.setCacheMode(self.CacheBackground)
if background is not None:
brush = fn.mkBrush(background)
self.setBackgroundBrush(brush)
self.setFocusPolicy(QtCore.Qt.StrongFocus)
self.setFrameShape(QtGui.QFrame.NoFrame)
self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.setTransformationAnchor(QtGui.QGraphicsView.NoAnchor)
self.setResizeAnchor(QtGui.QGraphicsView.AnchorViewCenter)
self.setViewportUpdateMode(QtGui.QGraphicsView.MinimalViewportUpdate)
#self.setSceneRect(QtCore.QRectF(-1e10, -1e10, 2e10, 2e10))
self.lockedViewports = []
self.lastMousePos = None
self.setMouseTracking(True)
self.aspectLocked = False
#self.yInverted = True
self.range = QtCore.QRectF(0, 0, 1, 1)
self.autoPixelRange = True
self.currentItem = None
self.clearMouse()
self.updateMatrix()
self.sceneObj = GraphicsScene()
self.setScene(self.sceneObj)
## by default we set up a central widget with a grid layout.
## this can be replaced if needed.
self.centralWidget = None
self.setCentralItem(QtGui.QGraphicsWidget())
self.centralLayout = QtGui.QGraphicsGridLayout()
self.centralWidget.setLayout(self.centralLayout)
self.mouseEnabled = False
self.scaleCenter = False ## should scaling center around view center (True) or mouse click (False)
self.clickAccepted = False
示例10: __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
示例11: 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
示例12: setBackground
def setBackground(self, background):
"""
Set the background color of the GraphicsView.
To use the defaults specified py pyqtgraph.setConfigOption, use background='default'.
To make the background transparent, use background=None.
"""
self._background = background
if background == 'default':
background = pyqtgraph.getConfigOption('background')
brush = fn.mkBrush(background)
self.setBackgroundBrush(brush)
示例13: __init__
def __init__(self, name, parent=None):
terms = {'coord': {'io': 'in'},
'data': {'io': 'in'},
'this': {'io': 'out'},
'All': {'io': 'out'}}
super(hydraulicGradientNode, self).__init__(name, terminals=terms)
self.graphicsItem().setBrush(fn.mkBrush(250, 250, 150, 150))
self._ctrlWidget = hydraulicGradientNodeCtrlWidget(self)
self._coords_id = None
示例14: __init__
def __init__(self, name, color=(200, 200, 200, 150), ui=None, parent=None, **kwargs):
self._parent = parent
kwargs['terminals'] = kwargs.get('terminals', {'In': {'io': 'in'}, 'Out': {'io': 'out'}})
super(NodeWithCtrlWidget, self).__init__(name, **kwargs)
logger.debug("about to create node [{0}] of type [{1}]".format(self.name(), self.nodeName))
self._init_at_first()
self.graphicsItem().setBrush(fn.mkBrush(color))
if ui is None:
ui = getattr(self, 'uiTemplate', [])
self._ctrlWidget = self._createCtrlWidget(parent=self, ui=ui)
logger.info("node [{0}] of type [{1}] created".format(self.name(), self.nodeName))
示例15: __init__
def __init__(self, name, parent=None):
super(QuickViewNode, self).__init__(name, terminals={'In': {'io': 'in'}})
self.graphicsItem().setBrush(fn.mkBrush(150, 150, 250, 200))
self._pandasDataModel = PandasDataModel(parent=self)
self._pandasHeaderModel = PandasHeaderModel(parent=self)
self._ctrlWidget = QuickViewCtrlWidget(self)
# connect show/hide signals
self._pandasHeaderModel.row_hidden.connect(self._ctrlWidget.tableView.horizontalHeader().hideSection) #argumnent [int]
self._pandasHeaderModel.row_showed.connect(self._ctrlWidget.tableView.horizontalHeader().showSection) #argumnent [int]
self._pandasDataModel.modelReset.connect(self._ctrlWidget.update) #no argument
self._id = None