Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
class TriggerBase(Node, QtCore.QObject):
_input_specs = {'signals' : dict(streamtype = 'signals')}
_output_specs = {'events' : dict(streamtype = 'events', dtype ='int64', shape = (-1, ))}
_default_params = [
{'name': 'channel', 'type': 'int', 'value': 0},
{'name': 'threshold', 'type': 'float', 'value': 0.},
{'name': 'front', 'type': 'list', 'value': '+' , 'values' : ['+', '-'] },
{'name': 'debounce_mode', 'type': 'list', 'value': 'no-debounce' ,
'values' : ['no-debounce', 'after-stable', 'before-stable'] },
{'name': 'debounce_time', 'type': 'float', 'value': 0.01},
]
new_params = QtCore.Signal(object)
def __init__(self, parent = None, **kargs):
QtCore.QObject.__init__(self, parent)
Node.__init__(self, **kargs)
self.params = pg.parametertree.Parameter.create( name='Trigger options',
type='group', children =self._default_params)
def _configure(self, max_size=2., emit_qt_signal=False):
self.max_size = max_size
self.params.sigTreeStateChanged.connect(self.on_params_change)
self.emit_qt_signal = emit_qt_signal
def after_input_connect(self, inputname):
self.nb_channel = self.input.params['shape'][1]
self.params.param('channel').setLimits([0, self.nb_channel-1])
:func:`register `,
:func:`unregister `
The ViewBox itself can be accessed by calling :func:`getViewBox() `
==================== =======================================================================
**Signals:**
sigYRangeChanged wrapped from :class:`ViewBox `
sigXRangeChanged wrapped from :class:`ViewBox `
sigRangeChanged wrapped from :class:`ViewBox `
==================== =======================================================================
"""
sigRangeChanged = QtCore.Signal(object, object) ## Emitted when the ViewBox range has changed
sigYRangeChanged = QtCore.Signal(object, object) ## Emitted when the ViewBox Y range has changed
sigXRangeChanged = QtCore.Signal(object, object) ## Emitted when the ViewBox X range has changed
lastFileDir = None
def __init__(self, parent=None, name=None, labels=None, title=None, viewBox=None, axisItems=None, enableMenu=True, **kargs):
"""
Create a new PlotItem. All arguments are optional.
Any extra keyword arguments are passed to PlotItem.plot().
============== ==========================================================================================
**Arguments:**
*title* Title to display at the top of the item. Html is allowed.
*labels* A dictionary specifying the axis labels to display::
{'left': (args), 'bottom': (args), ...}
The name of each axis and the corresponding arguments are passed to
>>> from sktracker import data
>>> from sktracker.trajectories import Trajectories
>>> trajs = data.brownian_trajs_df()
>>> trajs = Trajectories(trajs)
>>> # Relabel to true label
>>> trajs.relabel(trajs.true_label)
>>> tw = TrajectoriesWidget(trajs, names="My traj",
xaxis='t', yaxis='x',
scale_x=1, scale_y=1,
save_hook=None)
>>> tw.show()
"""
sig_traj_change = QtCore.Signal(int)
sig_axis_change = QtCore.Signal(str)
sig_update_trajectories = QtCore.Signal()
def __init__(self, trajs, names=None,
xaxis='t', yaxis='x',
scale_x=1, scale_y=1,
save_hook=None,
parent=None):
super().__init__(parent=parent)
self.setWindowTitle("Trajectories plot")
if parent is None:
self.resize(1000, 500)
if isinstance(trajs, list):
loader = UiLoader(baseinstance, customWidgets)
if workingDirectory is not None:
loader.setWorkingDirectory(workingDirectory)
widget = loader.load(uifile)
QMetaObject.connectSlotsByName(widget)
return widget
class SliderWidget(QtGui.QWidget):
'''
shows a horizontal/vertical slider with a label showing its value
'''
sigValueChanged = QtCore.Signal(object) # value
def __init__(self, horizontal=True, parent=None):
'''
horizontal -> True/False
'''
QtGui.QWidget.__init__(self, parent)
self.mn, self.mx = None, None
self.precission = 0
self.step = 100
self.valueLen = 2
self.label = QtGui.QLabel()
self.label.setFont(QtGui.QFont('Courier'))
self.slider = QtGui.QSlider(QtCore.Qt.Orientation(
1 if horizontal else 0), self) # 1...horizontal
self.slider.setTickPosition(
if o.get('hidden', False):
w.hide()
label = l.labelForField(w)
label.hide()
ctrls[k] = w
w.rowNum = row
row += 1
group = WidgetGroup(widget)
return widget, group, ctrls
class CtrlNode(Node):
"""Abstract class for nodes with auto-generated control UI"""
sigStateChanged = QtCore.Signal(object)
def __init__(self, name, ui=None, terminals=None):
if ui is None:
if hasattr(self, 'uiTemplate'):
ui = self.uiTemplate
else:
ui = []
if terminals is None:
terminals = {'In': {'io': 'in'}, 'Out': {'io': 'out', 'bypass': 'In'}}
Node.__init__(self, name=name, terminals=terminals)
self.ui, self.stateGroup, self.ctrls = generateUi(ui)
self.stateGroup.sigChanged.connect(self.changed)
def ctrlWidget(self):
return self.ui
"""
Node represents the basic processing unit of a flowchart.
A Node subclass implements at least:
1) A list of input / ouptut terminals and their properties
2) a process() function which takes the names of input terminals as keyword arguments and returns a dict with the names of output terminals as keys.
A flowchart thus consists of multiple instances of Node subclasses, each of which is connected
to other by wires between their terminals. A flowchart is, itself, also a special subclass of Node.
This allows Nodes within the flowchart to connect to the input/output nodes of the flowchart itself.
Optionally, a node class can implement the ctrlWidget() method, which must return a QWidget (usually containing other widgets) that will be displayed in the flowchart control panel. Some nodes implement fairly complex control widgets, but most nodes follow a simple form-like pattern: a list of parameter names and a single value (represented as spin box, check box, etc..) for each parameter. To make this easier, the CtrlNode subclass allows you to instead define a simple data structure that CtrlNode will use to automatically generate the control widget. """
sigOutputChanged = QtCore.Signal(object) # self
sigClosed = QtCore.Signal(object)
sigRenamed = QtCore.Signal(object, object)
sigTerminalRenamed = QtCore.Signal(object, object) # term, oldName
sigTerminalAdded = QtCore.Signal(object, object) # self, term
sigTerminalRemoved = QtCore.Signal(object, object) # self, term
def __init__(self, name, terminals=None, allowAddInput=False, allowAddOutput=False, allowRemove=True):
"""
============== ============================================================
**Arguments:**
name The name of this specific node instance. It can be any
string, but must be unique within a flowchart. Usually,
we simply let the flowchart decide on a name when calling
Flowchart.addNode(...)
terminals Dict-of-dicts specifying the terminals present on this Node.
Terminal specifications look like::
# -*- coding: utf-8 -*-
from ..Qt import QtCore, QtGui
if not hasattr(QtCore, 'Signal'):
QtCore.Signal = QtCore.pyqtSignal
import weakref
class CanvasManager(QtCore.QObject):
SINGLETON = None
sigCanvasListChanged = QtCore.Signal()
def __init__(self):
if CanvasManager.SINGLETON is not None:
raise Exception("Can only create one canvas manager.")
CanvasManager.SINGLETON = self
QtCore.QObject.__init__(self)
self.canvases = weakref.WeakValueDictionary()
@classmethod
def instance(cls):
from ..Qt import QtCore, QtGui
from .DockDrop import *
from ..widgets.VerticalLabel import VerticalLabel
from ..python2_3 import asUnicode
class Dock(QtGui.QWidget, DockDrop):
sigStretchChanged = QtCore.Signal()
sigClosed = QtCore.Signal(object)
def __init__(self, name, area=None, size=(10, 10), widget=None, hideTitle=False, autoOrientation=True, closable=False):
QtGui.QWidget.__init__(self)
DockDrop.__init__(self)
self._container = None
self._name = name
self.area = area
self.label = DockLabel(name, self, closable)
if closable:
self.label.sigCloseClicked.connect(self.close)
self.labelHidden = False
self.moveLabel = True ## If false, the dock is no longer allowed to move the label.
self.autoOrient = autoOrientation
self.orientation = 'horizontal'
#self.label.setAlignment(QtCore.Qt.AlignHCenter)
self.topLayout = QtGui.QGridLayout()
Handles may be dragged to change the position, size, orientation, or other
properties of the ROI they are attached to.
"""
types = { ## defines number of sides, start angle for each handle type
't': (4, np.pi/4),
'f': (4, np.pi/4),
's': (4, 0),
'r': (12, 0),
'sr': (12, 0),
'rf': (12, 0),
}
sigClicked = QtCore.Signal(object, object) # self, event
sigRemoveRequested = QtCore.Signal(object) # self
def __init__(self, radius, typ=None, pen=(200, 200, 220), parent=None, deletable=False):
#print " create item with parent", parent
#self.bounds = QtCore.QRectF(-1e-10, -1e-10, 2e-10, 2e-10)
#self.setFlags(self.ItemIgnoresTransformations | self.ItemSendsScenePositionChanges)
self.rois = []
self.radius = radius
self.typ = typ
self.pen = fn.mkPen(pen)
self.currentPen = self.pen
self.pen.setWidth(0)
self.pen.setCosmetic(True)
self.isMoving = False
self.sides, self.startAng = self.types[typ]
self.buildPath()
self._shape = None
Box that allows internal scaling/panning of children by mouse drag.
This class is usually created automatically as part of a :class:`PlotItem ` or :class:`Canvas ` or with :func:`GraphicsLayout.addViewBox() `.
Features:
* Scaling contents by mouse or auto-scale when contents change
* View linking--multiple views display the same data ranges
* Configurable by context menu
* Item coordinate mapping methods
"""
sigYRangeChanged = QtCore.Signal(object, object)
sigXRangeChanged = QtCore.Signal(object, object)
sigRangeChangedManually = QtCore.Signal(object)
sigRangeChanged = QtCore.Signal(object, object)
sigStateChanged = QtCore.Signal(object)
sigTransformChanged = QtCore.Signal(object)
sigResized = QtCore.Signal(object)
## mouse modes
PanMode = 3
RectMode = 1
## axes
XAxis = 0
YAxis = 1
XYAxes = 2
## for linking views together
NamedViews = weakref.WeakValueDictionary() # name: ViewBox
AllViews = weakref.WeakKeyDictionary() # ViewBox: None