How to use the plottr.QtCore.pyqtSignal function in plottr

To help you get started, we’ve selected a few plottr examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github data-plottr / plottr / plottr / gui / widgets.py View on Github external
self.elements[lbl] = widget
            layout.addRow(lbl, widget)

        self.setLayout(layout)


class MonitorIntervalInput(QtGui.QWidget):
    """
    Simple form-like widget for entering a monitor/refresh interval.
    Only has a label and a spin-box as input.

    It's signal `intervalChanged(int)' is emitted when the value
    of the spinbox has changed.
    """

    intervalChanged = QtCore.pyqtSignal(int)

    def __init__(self, parent=None):
        super().__init__(parent)

        self.spin = QtGui.QSpinBox()
        layout = QtGui.QFormLayout()
        layout.addRow('Refresh interval (s)', self.spin)
        self.setLayout(layout)

        self.spin.valueChanged.connect(self.spinValueChanged)

    @QtCore.pyqtSlot(int)
    def spinValueChanged(self, val):
        self.intervalChanged.emit(val)
github data-plottr / plottr / plottr / node / grid.py View on Github external
from ..gui.icons import gridIcon

__author__ = 'Wolfgang Pfaff'
__license__ = 'MIT'


@unique
class GridOption(Enum):
    noGrid = 0
    guessShape = 1
    specifyShape = 2


class ShapeSpecificationWidget(QtGui.QWidget):
    #: signal that is emitted when we want to communicate a new shape
    newShapeNotification = QtCore.pyqtSignal(tuple)

    def __init__(self, parent=None):
        super().__init__(parent)

        self._axes = []
        self._widgets = {}

        self.layout = QtGui.QFormLayout()
        self.confirm = QtGui.QPushButton('set')
        self.layout.addRow(self.confirm)
        self.setLayout(self.layout)

        self.confirm.clicked.connect(self.signalShape)

    def signalShape(self):
        self.newShapeNotification.emit(self.getShape())
github data-plottr / plottr / plottr / gui / data_display.py View on Github external
"""data_display_widgets.py

UI elements for inspecting data structure and content.
"""

from typing import Union, List, Tuple, Dict

from .. import QtGui, QtCore
from ..data.datadict import DataDictBase


class DataSelectionWidget(QtGui.QTreeWidget):
    """A simple tree widget to show data fields and dependencies."""

    #: signal (List[str]) that is emitted when the selection is modified.
    dataSelectionMade = QtCore.pyqtSignal(list)

    def __init__(self, parent: QtGui.QWidget = None, readonly: bool = False):
        super().__init__(parent)

        self.setColumnCount(3)
        self.setHeaderLabels(['Name', 'Dependencies', 'Size'])
        self.dataItems = {}

        self._dataStructure = DataDictBase()
        self._dataShapes = {}
        self._readonly = readonly

        self.setSelectionMode(self.MultiSelection)
        self.itemSelectionChanged.connect(self.emitSelection)

    def _makeItem(self, name):
github data-plottr / plottr / plottr / node / node.py View on Github external
Base class for Node control widgets.

    For the widget class to set up communication with the Node automatically,
    make sure to set :attr:`plottr.node.node.NodeWidget.optGetters` and
    :attr:`plottr.node.node.NodeWidget.optSetters` for a widget class.
    """

    #: icon for this node
    icon = None

    #: preferred location of the widget when used as dock widget
    preferredDockWidgetArea = QtCore.Qt.LeftDockWidgetArea

    #: signal (args: object)) to emit to notify the node of a (changed)
    #: user option.
    optionToNode = QtCore.pyqtSignal(object)

    #: signal (args: (object)) all options to the node.
    allOptionsToNode = QtCore.pyqtSignal(object)

    def __init__(self, parent: QtGui.QWidget = None,
                 embedWidgetClass: QtGui.QWidget = None,
                 node: Node = None):
        super().__init__(parent)

        self.optGetters = {}
        self.optSetters = {}
        self.node = node

        self._emitGuiChange = True

        self.widget = None
github data-plottr / plottr / plottr / node / dim_reducer.py View on Github external
:reductions: ``Dict[str, (callable, *args, **kwargs)]``
        reduction functions. Keys are the axis names the reductions are applied
        to; values are tuples of the reduction function, and optional
        arguments and kw-arguments.
        The function can also be via :class:`ReductionMethod`.
        The function must accept an ``axis = `` keyword, and must return
        an array of dimensionality that is reduced by one compared to its
        input.
    """

    nodeName = 'DimensionReducer'
    uiClass = DimensionReducerNodeWidget

    #: A signal that emits (structure, shapes, type) when data structure has
    #: changed.
    newDataStructure = QtCore.pyqtSignal(object, object, object)

    def __init__(self, *arg, **kw):
        self._reductions = {}
        self._targetNames = None
        self._dataStructure = None

        super().__init__(*arg, **kw)

    # Properties

    @property
    def reductions(self):
        return self._reductions

    @reductions.setter
    @updateOption('reductions')
github data-plottr / plottr / plottr / node / node.py View on Github external
#: signal emitted when any available data fields change (dep. and indep.)
    #: emits a the list of names of new axes
    dataFieldsChanged = Signal(list)

    #: signal emitted when data type changes
    dataTypeChanged = Signal(object)

    #: signal emitted when data structure changes (fields, or dtype)
    dataStructureChanged = Signal(object)

    #: signal emitted when data shapes change
    dataShapesChanged = Signal(dict)

    #: when data structure changes, emits (structure, shapes, type)
    newDataStructure = QtCore.pyqtSignal(object, object, object)

    #: developer flag for whether we actually want to raise of use the logging
    #: system
    _raiseExceptions = False

    def __init__(self, name: str):
        """Create a new instance of the Node.

        :param name: name of the instance.
        """
        super().__init__(name, terminals=self.__class__.terminals)

        self.signalUpdate = True
        self.dataAxes = None
        self.dataDependents = None
        self.dataType = None
github data-plottr / plottr / plottr / node / grid.py View on Github external
if shape == tuple():
            shape = [0 for ax in self._axes]
        for s, ax in zip(shape, self._axes):
            self._widgets[ax].setValue(s)

    def getShape(self):
        return tuple(self._widgets[ax].value() for ax in self._axes)

    def enableEditing(self, enable):
        for ax, w in self._widgets.items():
            w.setEnabled(enable)
        self.confirm.setEnabled(enable)


class GridOptionWidget(QtGui.QWidget):
    optionSelected = QtCore.pyqtSignal(object)

    def __init__(self, parent=None):
        super().__init__(parent)

        self._emitUpdate = True

        #  make radio buttons and layout ##
        self.buttons = {
            GridOption.noGrid: QtGui.QRadioButton('No grid'),
            GridOption.guessShape: QtGui.QRadioButton('Guess shape'),
            GridOption.specifyShape: QtGui.QRadioButton('Specify shape'),
        }

        btnLayout = QtGui.QVBoxLayout()
        self.btnGroup = QtGui.QButtonGroup(self)