Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if os.path.isdir(abspath):
ret_ = findFilesByExtension(abspath, extensions)
if len(ret_) > 0:
ret += ret_
else:
if os.path.splitext(c)[-1] in extensions:
ret += [abspath]
return ret
class DataFileContent(QtWidgets.QTreeWidget):
#: Signal(str) -- Emitted when the user requests a plot for datadict
#: Arguments:
#: - name of the group within the currently selected file
plotRequested = Signal(str)
def __init__(self, parent=None):
super().__init__(parent)
self.data = {}
self.groupItems = []
self.selectedGroup = None
self.dataPopup = QtWidgets.QMenu('Data actions', self)
self.plotAction = self.dataPopup.addAction("Plot")
self.plotAction.triggered.connect(self.onPlotActionTriggered)
@Slot(object)
def setData(self, data: Dict[str, DataDict]):
"""Set the data to display."""
#: arguments is a dictionary of options and new values.
optionChangeNotification = QtCore.pyqtSignal(dict)
#: signal emitted when available data axes change
#: emits a the list of names of new axes
dataAxesChanged = Signal(list)
#: 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.
"""
from typing import List
from plottr import QtGui, Signal, Slot
from plottr.node import Node, NodeWidget, updateOption
from plottr.node.node import updateGuiQuietly, emitGuiUpdate
from plottr.gui.widgets import FormLayoutWrapper
from plottr.data.datadict import DataDictBase, MeshgridDataDict
class DimensionCombo(QtGui.QComboBox):
dimensionSelected = Signal(str)
def __init__(self, parent=None, dimensionType='axes'):
super().__init__(parent)
self.node = None
self.dimensionType = dimensionType
self.clear()
self.entries = ['None']
for e in self.entries:
self.addItem(e)
self.currentTextChanged.connect(self.signalDimensionSelection)
def connectNode(self, node: Node = None):
self.node = node
__license__ = 'MIT'
class PlotNode(Node):
"""
Basic Plot Node, derived from :class:`plottr.node.node.Node`.
At the moment this doesn't do much besides passing data to the plotting widget.
Data is just passed through.
On receipt of new data, :attr:`newPlotData` is emitted.
"""
nodeName = 'Plot'
#: Signal emitted when :meth:`process` is called, with the data passed to
#: it as argument.
newPlotData = Signal(object)
def __init__(self, name: str):
"""Constructor for :class:`PlotNode`. """
super().__init__(name=name)
self.plotWidgetContainer = None
def setPlotWidgetContainer(self, w: 'PlotWidgetContainer'):
"""Set the plot widget container.
Makes sure that newly arriving data is sent to plot GUI elements.
:param w: container to connect the node to.
"""
self.plotWidgetContainer = w
self.newPlotData.connect(self.plotWidgetContainer.setData)
#: signal emitted when available data axes change
#: emits a the list of names of new axes
dataAxesChanged = Signal(list)
#: 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
uiVisibleByDefault = False
#: A signal to notify the UI of option changes
#: arguments is a dictionary of options and new values.
optionChangeNotification = QtCore.pyqtSignal(dict)
#: signal emitted when available data axes change
#: emits a the list of names of new axes
dataAxesChanged = Signal(list)
#: 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.
#: instance of the widget is created, and signal/slots are connected.
uiClass = None
#: Whether or not to automatically set up a UI widget.
useUi = True
#: Whether the ui should be visible by default
uiVisibleByDefault = False
#: A signal to notify the UI of option changes
#: arguments is a dictionary of options and new values.
optionChangeNotification = QtCore.pyqtSignal(dict)
#: signal emitted when available data axes change
#: emits a the list of names of new axes
dataAxesChanged = Signal(list)
#: 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)
useUi = True
#: Whether the ui should be visible by default
uiVisibleByDefault = False
#: A signal to notify the UI of option changes
#: arguments is a dictionary of options and new values.
optionChangeNotification = QtCore.pyqtSignal(dict)
#: signal emitted when available data axes change
#: emits a the list of names of new axes
dataAxesChanged = Signal(list)
#: 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
import h5py
from .. import QtCore, QtWidgets, Signal, Slot
from ..data.datadict import DataDict
from ..data.datadict_storage import datadict_from_hdf5, all_datadicts_from_hdf5
from ..apps.autoplot import autoplotDDH5
from .ui.Monitr_UI import Ui_MainWindow
class Monitr(QtWidgets.QMainWindow):
#: Signal(object) -- emitted when a valid data file is selected.
#: Arguments:
#: - a dictionary containing the datadicts found in the file (as top-level groups)
dataFileSelected = Signal(object)
def __init__(self, monitorPath: str = '.', refreshInterval: int = 1,
parent=None):
super().__init__(parent=parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.plotDialogs = {}
self.selectedFile = None
self.newFiles = []
self.monitorPath = os.path.abspath(monitorPath)
self.refreshInterval = refreshInterval
self.refreshFiles = partial(self.ui.fileList.loadFromPath, self.monitorPath,
emitNew=True)
if inputData is not None:
win.setInput(data=inputData)
return fc, win
class UpdateToolBar(QtGui.QToolBar):
"""
A very simple toolbar to enable monitoring or triggering based on a timer.
Contains a timer whose interval can be set.
The toolbar will then emit a signal each interval.
"""
#: Signal emitted after each trigger interval
trigger = Signal()
def __init__(self, name, parent=None):
super().__init__(name, parent)
self.monitorInput = MonitorIntervalInput()
self.monitorInput.setToolTip('Set to 0 for disabling triggering')
self.monitorInput.intervalChanged.connect(self.setMonitorInterval)
self.addWidget(self.monitorInput)
self.monitor = QtCore.QTimer()
self.monitor.timeout.connect(self.monitorTriggered)
Slot()
def monitorTriggered(self):
"""
Is called whenever the monitor timer triggers, and emit the