Exemplo n.º 1
0
Arquivo: log.py Projeto: wpfff/plottr
def logDialog(widget: QtWidgets.QWidget) -> QtWidgets.QDialog:
    layout = QtWidgets.QVBoxLayout()
    d = QtWidgets.QDialog()
    d.setLayout(layout)
    layout.addWidget(widget)
    d.setWindowTitle('Plottr | Log')
    return d
Exemplo n.º 2
0
    def __init__(self, node: Node):
        super().__init__(node=node)
        assert self.node is not None

        self.fileinput = QtWidgets.QLineEdit()
        self.groupinput = QtWidgets.QLineEdit('data')
        self.reload = QtWidgets.QPushButton('Reload')

        self.optSetters = {
            'filepath': self.fileinput.setText,
            'groupname': self.groupinput.setText,
        }
        self.optGetters = {
            'filepath': self.fileinput.text,
            'groupname': self.groupinput.text,
        }

        flayout = QtWidgets.QFormLayout()
        flayout.addRow('File path:', self.fileinput)
        flayout.addRow('Group:', self.groupinput)

        vlayout = QtWidgets.QVBoxLayout()
        vlayout.addLayout(flayout)
        vlayout.addWidget(self.reload)

        self.setLayout(vlayout)

        self.fileinput.textEdited.connect(
            lambda x: self.signalOption('filepath')
        )
        self.groupinput.textEdited.connect(
            lambda x: self.signalOption('groupname')
        )
        self.reload.pressed.connect(self.node.update)
Exemplo n.º 3
0
    def __init__(self, parent: Optional[QtWidgets.QWidget] = None):
        super().__init__(parent)

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

        self.spin.valueChanged.connect(self.spinValueChanged)
Exemplo n.º 4
0
    def __init__(self, parent: Optional[QtWidgets.QWidget] = None):
        super().__init__(parent)

        self._axes: List[str] = []
        self._widgets: Dict[int, Dict[str, QtWidgets.QWidget]] = {}
        self._processChanges = True

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

        self.confirm.clicked.connect(self.signalShape)
Exemplo n.º 5
0
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(935, 569)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget)
        self.verticalLayout.setObjectName("verticalLayout")
        self.splitter = QtWidgets.QSplitter(self.centralwidget)
        self.splitter.setOrientation(QtCore.Qt.Horizontal)
        self.splitter.setObjectName("splitter")
        self.fileList = DataFileList(self.splitter)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                           QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(1)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.fileList.sizePolicy().hasHeightForWidth())
        self.fileList.setSizePolicy(sizePolicy)
        self.fileList.setAlternatingRowColors(False)
        self.fileList.setUniformRowHeights(True)
        self.fileList.setObjectName("fileList")
        self.fileContents = DataFileContent(self.splitter)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                           QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(2)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.fileContents.sizePolicy().hasHeightForWidth())
        self.fileContents.setSizePolicy(sizePolicy)
        self.fileContents.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.fileContents.setUniformRowHeights(True)
        self.fileContents.setAllColumnsShowFocus(False)
        self.fileContents.setObjectName("fileContents")
        self.verticalLayout.addWidget(self.splitter)
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 935, 22))
        self.menubar.setObjectName("menubar")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)
        self.monitorToolBar = MonitorToolBar(MainWindow)
        self.monitorToolBar.setObjectName("monitorToolBar")
        MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.monitorToolBar)
        self.autoPlotNewAction = QtWidgets.QAction(MainWindow)
        self.autoPlotNewAction.setCheckable(True)
        self.autoPlotNewAction.setObjectName("autoPlotNewAction")
        self.monitorToolBar.addAction(self.autoPlotNewAction)

        self.retranslateUi(MainWindow)
        MainWindow.dataFileSelected.connect(self.fileContents.setData)
        self.fileList.dataFileSelected.connect(MainWindow.processFileSelection)
        self.fileContents.customContextMenuRequested['QPoint'].connect(
            self.fileContents.onCustomContextMenuRequested)
        self.fileContents.plotRequested.connect(MainWindow.plotSelected)
        self.fileList.itemSelectionChanged.connect(
            self.fileList.processSelection)
        self.fileList.newDataFilesFound.connect(MainWindow.onNewDataFilesFound)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
Exemplo n.º 6
0
Arquivo: log.py Projeto: wpfff/plottr
    def __init__(self, parent: Optional[QtWidgets.QWidget] = None,
                 level: int = logging.INFO):
        super().__init__(parent)

        ### set up the graphical handler
        fmt = logging.Formatter(
            "%(asctime)s - %(name)s - %(levelname)s\n" +
                "    %(message)s",
            datefmt='%Y-%m-%d %H:%M:%S',
            )
        logTextBox = QLogHandler(self)
        logTextBox.setFormatter(fmt)

        # make the widget
        layout = QtWidgets.QVBoxLayout()
        layout.addWidget(logTextBox.widget)
        self.setLayout(layout)

        # configure the logger. delete pre-existing graphical handler.
        self.logger = getLogger()
        for h in self.logger.handlers:
            if isinstance(h, QLogHandler):
                self.logger.removeHandler(h)
                h.widget.deleteLater()
                del h

        self.logger.addHandler(logTextBox)
        self.logger.setLevel(level)
Exemplo n.º 7
0
def subtractAverage():
    x = np.arange(11) - 5.
    y = np.linspace(0, 10, 51)
    xx, yy = np.meshgrid(x, y, indexing='ij')
    zz = np.sin(yy) + xx
    data = MeshgridDataDict(x=dict(values=xx),
                            y=dict(values=yy),
                            z=dict(values=zz, axes=['x', 'y']))
    data.validate()

    x = np.arange(11) - 5.
    y = np.linspace(0, 10, 51)
    xx, yy = np.meshgrid(x, y, indexing='ij')
    zz = np.sin(yy) + xx
    data2 = MeshgridDataDict(reps=dict(values=xx),
                             y=dict(values=yy),
                             z=dict(values=zz, axes=['reps', 'y']))
    data2.validate()

    # make app and gui, fc
    app = QtWidgets.QApplication([])
    win, fc = makeFlowchartWithPlotWindow([('sub', SubtractAverage)])
    win.show()

    # feed in data
    fc.setInput(dataIn=data)
    fc.setInput(dataIn=data2)

    return app.exec_()
Exemplo n.º 8
0
    def showContextMenu(self, position: QtCore.QPoint) -> None:
        model_index = self.indexAt(position)
        item = self.itemFromIndex(model_index)
        current_tag_char = item.text(1)

        menu = QtWidgets.QMenu()

        copy_icon = self.style().standardIcon(
            QtWidgets.QStyle.SP_DialogSaveButton)
        copy_action = menu.addAction(copy_icon, "Copy")

        star_action = self.window().starAction
        star_action.setText(
            'Star' if current_tag_char != self.tag_dict['star'] else 'Unstar')
        menu.addAction(star_action)

        cross_action = self.window().crossAction
        cross_action.setText('Cross' if current_tag_char != self.
                             tag_dict['cross'] else 'Uncross')
        menu.addAction(cross_action)

        action = menu.exec_(self.mapToGlobal(position))
        if action == copy_action:
            QtWidgets.QApplication.clipboard().setText(
                item.text(model_index.column()))
Exemplo n.º 9
0
    def addNodeWidget(self, node: Node, **kwargs: Any) -> None:
        """
        Add a node widget as dock.

        :param node: node for which to add the widget.

        :keyword arguments:
            * *visible* (`bool`; default: taken from widget class definition) --
              whether the widget is visible from the start
            * *dockArea* (`QtCore.Qt.DockWidgetArea`; default: taken from class) --
              where the dock widget initially sits in the window
            * *icon* (`QtCore.QIcon`; default: taken from class) --
              an icon to use for the toolbar
        """

        if node.useUi and node.ui is not None and node.uiClass is not None:
            dockArea = kwargs.get('dockArea', node.ui.preferredDockWidgetArea)
            visible = kwargs.get('visible', node.uiVisibleByDefault)
            icon = kwargs.get('icon', node.ui.icon)

            d = QtWidgets.QDockWidget(node.name(), self)
            d.setWidget(node.ui)
            self.nodeWidgets[node.name()] = d
            self.addDockWidget(dockArea, d)

            action = d.toggleViewAction()
            if icon is not None:
                action.setIcon(icon)
            self.nodeToolBar.addAction(action)

            if not visible:
                d.close()
def main():
    app = QtWidgets.QApplication([])
    widgets = []

    widgets.append(test_basic_line_plot())
    # widgets.append(
    #     test_images())
    # widgets.append(
    #     test_scatter2d())
    # widgets.append(
    #     test_complex_line_plots())
    # widgets.append(
    #     test_complex_line_plots(single_panel=True))
    # widgets.append(
    #     test_complex_line_plots(mag_and_phase_format=True))
    # widgets.append(
    #     test_complex_line_plots(single_panel=True, mag_and_phase_format=True))
    # widgets.append(
    #     test_complex_images())
    # widgets.append(
    #     test_complex_images(mag_and_phase_format=True))

    dgs = []
    for w in widgets:
        dgs.append(widgetDialog(w))
        dgs[-1].show()
    return app.exec_()
Exemplo n.º 11
0
 def addModuleComboBox(self) -> QtWidgets.QComboBox:
     """ Set up the model function drop down manual widget.
     """
     combo = QtWidgets.QComboBox()
     combo.setEditable(False)
     for module_name in self.fitting_modules:
         combo.addItem(module_name)
     return combo
Exemplo n.º 12
0
Arquivo: grid.py Projeto: wpfff/plottr
    def _addAxis(self, idx: int, name: str) -> None:
        nameWidget = QtWidgets.QComboBox()
        for j, bx in enumerate(self._axes):
            nameWidget.addItem(bx)
        nameWidget.setCurrentText(name)

        dimLenWidget = QtWidgets.QSpinBox()
        dimLenWidget.setMinimum(1)
        dimLenWidget.setMaximum(999999)
        self._widgets[idx] = {
            'name': nameWidget,
            'shape': dimLenWidget,
        }
        self.layout().insertRow(idx, nameWidget, dimLenWidget)

        nameWidget.currentTextChanged.connect(
            lambda x: self._processAxisChange(idx, x))
Exemplo n.º 13
0
def main():
    plottrlog.LEVEL = logging.DEBUG
    data = make_data()

    app = QtWidgets.QApplication([])
    fc, win = autoplot(inputData=data)

    if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
        QtWidgets.QApplication.instance().exec_()
Exemplo n.º 14
0
def main(dbPath: Optional[str]) -> None:
    app = QtWidgets.QApplication([])
    plottrlog.enableStreamHandler(True)

    win = inspectr(dbPath=dbPath)
    win.show()

    if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
        QtWidgets.QApplication.instance().exec_()
Exemplo n.º 15
0
 def __init__(self, parent: Optional[QtWidgets.QWidget] = None):
     super().__init__(
         parent=parent,
         elements=[('Hist. axis', DimensionCombo(dimensionType='axes')),
                   ('# of bins', QtWidgets.QSpinBox())],
     )
     self.combo = self.elements['Hist. axis']
     self.nbins = self.elements['# of bins']
     self.nbins.setRange(3, 10000)
Exemplo n.º 16
0
 def _paramFixCheck(self, default_value: bool = False) -> QtWidgets.QCheckBox:
     """generate a push checkbox for the parameter fix option.
     :param default_value : param is fixed by default or not
     :returns: a checkbox widget
     """
     widget = QtWidgets.QCheckBox('')
     widget.setChecked(default_value)
     widget.setToolTip("when fixed, the parameter will be fixed to the "
                       "initial guess value during fitting")
     return widget
Exemplo n.º 17
0
    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)
Exemplo n.º 18
0
    def __init__(self, parent: Optional[QtWidgets.QWidget] = None):
        super().__init__(parent)

        self.data: Dict[str, DataDict] = {}
        self.groupItems: List[QtWidgets.QTreeWidgetItem] = []
        self.selectedGroup = None

        self.dataPopup = QtWidgets.QMenu('Data actions', self)
        self.plotAction = self.dataPopup.addAction("Plot")
        self.plotAction.triggered.connect(self.onPlotActionTriggered)
Exemplo n.º 19
0
 def copy_to_clipboard(self, position: QtCore.QPoint) -> None:
     menu = QtWidgets.QMenu()
     copy_icon = self.style().standardIcon(
         QtWidgets.QStyle.SP_DialogSaveButton)
     copy_action = menu.addAction(copy_icon, "Copy")
     action = menu.exec_(self.mapToGlobal(position))
     if action == copy_action:
         model_index = self.indexAt(position)
         item = self.itemFromIndex(model_index)
         QtWidgets.QApplication.clipboard().setText(
             item.text(model_index.column()))
Exemplo n.º 20
0
Arquivo: grid.py Projeto: wpfff/plottr
    def __init__(self, parent: Optional[QtWidgets.QWidget] = None):
        super().__init__(parent)

        self._emitUpdate = True

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

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

        for opt in GridOption:
            btn = self.buttons[opt]
            self.btnGroup.addButton(btn, opt.value)
            btnLayout.addWidget(btn)

        # make shape spec widget
        self.shapeSpec = ShapeSpecificationWidget()
        shapeLayout = QtWidgets.QVBoxLayout()
        shapeLayout.addWidget(self.shapeSpec)
        shapeBox = QtWidgets.QGroupBox()
        shapeBox.setLayout(shapeLayout)

        # Widget layout
        layout = QtWidgets.QVBoxLayout()
        layout.addLayout(btnLayout)
        layout.addWidget(shapeBox)
        layout.addStretch()
        self.setLayout(layout)

        # Connect signals/slots #
        self.btnGroup.buttonToggled.connect(self.gridButtonSelected)
        self.shapeSpec.confirm.clicked.connect(self.shapeSpecified)

        # Default settings
        self.buttons[GridOption.noGrid].setChecked(True)
        self.enableShapeEdit(False)
Exemplo n.º 21
0
    def __init__(self, parent: Optional[QtWidgets.QWidget] = None) -> None:
        super().__init__(parent)

        #: central layout of the widget. only contains a graphics layout.
        layout = QtWidgets.QHBoxLayout(self)
        #: ``pyqtgraph`` graphics layout
        self.graphicsLayout = pg.GraphicsLayoutWidget(self)

        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)
        self.setLayout(layout)
        layout.addWidget(self.graphicsLayout)
Exemplo n.º 22
0
    def setData(self, data: Dict[str, DataDict]):
        """Set the data to display."""
        self.clear()
        self.data = {}
        self.groupItems = []

        for grpName, grpData in data.items():
            self.data[grpName] = data[grpName]
            grpItem = QtWidgets.QTreeWidgetItem(self, [grpName])
            self.groupItems.append(grpItem)
            self.addTopLevelItem(grpItem)
            dataParent = QtWidgets.QTreeWidgetItem(grpItem, ['[DATA]'])
            metaParent = QtWidgets.QTreeWidgetItem(grpItem, ['[META]'])

            for dn, dv in grpData.data_items():
                vals = [grpData.label(dn), str(grpData.meta_val('shape', dn))]
                if dn in grpData.dependents():
                    vals.append(f'Data (depends on {str(tuple(grpData.axes(dn)))[1:]}')
                else:
                    vals.append('Data (independent)')
                ditem = QtWidgets.QTreeWidgetItem(dataParent, vals)

                for mn, mv in grpData.meta_items(dn):
                    vals = [mn, str(mv)]
                    _ = QtWidgets.QTreeWidgetItem(ditem, vals)

            for mn, mv in grpData.meta_items():
                vals = [mn, str(mv)]
                _ = QtWidgets.QTreeWidgetItem(metaParent, vals)

            grpItem.setExpanded(True)
            dataParent.setExpanded(True)

        for i in range(self.columnCount()-1):
            self.resizeColumnToContents(i)
Exemplo n.º 23
0
    def __init__(self, parent: Optional[QtWidgets.QWidget] = None):
        super().__init__(parent)

        self.buttons = {
            ScaleUnitsOption.never: QtWidgets.QRadioButton('Never'),
            ScaleUnitsOption.always: QtWidgets.QRadioButton('Always'),
        }
        btnLayout = QtWidgets.QVBoxLayout()
        self.btnGroup = QtWidgets.QButtonGroup(self)

        for opt in ScaleUnitsOption:
            btn = self.buttons[opt]
            self.btnGroup.addButton(btn, opt.value)
            btnLayout.addWidget(btn)

        layout = QtWidgets.QVBoxLayout()
        layout.addLayout(btnLayout)
        layout.addStretch()
        self.setLayout(layout)
        self.buttons[ScaleUnitsOption.always].setChecked(True)

        self.btnGroup.buttonToggled.connect(self.unitscale_button_selected)
Exemplo n.º 24
0
    def __init__(self,
                 elements: List[Tuple[str, QtWidgets.QWidget]],
                 parent: Union[None, QtWidgets.QWidget] = None):
        super().__init__(parent)

        self.elements = {}

        layout = QtWidgets.QFormLayout()
        for lbl, widget in elements:
            self.elements[lbl] = widget
            layout.addRow(lbl, widget)

        self.setLayout(layout)
Exemplo n.º 25
0
    def __init__(self, parent: Optional[QtWidgets.QWidget] = None):
        """Constructor for :class:`._FigureMakerWidget`.

        :param parent: parent widget.
        """
        super().__init__(parent=parent)

        self.subPlots: List[PlotBase] = []

        layout = QtWidgets.QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)
        self.setLayout(layout)
Exemplo n.º 26
0
    def __init__(self, options: FigureOptions,
                 parent: Optional[QtWidgets.QWidget] = None) -> None:
        """Constructor.

        :param options: options object. GUI interaction will make changes
            in-place to this object.
        :param parent: parent Widget
        """
        super().__init__(parent)

        self.options = options

        combineLinePlots = self.addAction("Combine 1D")
        combineLinePlots.setCheckable(True)
        combineLinePlots.setChecked(self.options.combineLinePlots)
        combineLinePlots.triggered.connect(
            lambda: self._setOption('combineLinePlots',
                                    combineLinePlots.isChecked())
        )

        complexOptions = QtWidgets.QMenu(parent=self)
        complexGroup = QtWidgets.QActionGroup(complexOptions)
        complexGroup.setExclusive(True)
        for k in ComplexRepresentation:
            a = QtWidgets.QAction(k.label, complexOptions)
            a.setCheckable(True)
            complexGroup.addAction(a)
            complexOptions.addAction(a)
            a.setChecked(k == self.options.complexRepresentation)
        complexGroup.triggered.connect(
            lambda _a: self._setOption('complexRepresentation',
                                       ComplexRepresentation.fromLabel(_a.text()))
        )
        complexButton = QtWidgets.QToolButton()
        complexButton.setToolButtonStyle(QtCore.Qt.ToolButtonTextOnly)
        complexButton.setText('Complex')
        complexButton.setPopupMode(QtWidgets.QToolButton.InstantPopup)
        complexButton.setMenu(complexOptions)
        self.addWidget(complexButton)
Exemplo n.º 27
0
def main():
    app = QtWidgets.QApplication([])

    # flowchart and window
    nodes = makeNodeList()
    win, fc = makeFlowchartWithPlotWindow(nodes)
    win.show()

    # feed in data
    data = makeData()
    fc.setInput(dataIn=data)

    return app.exec_()
Exemplo n.º 28
0
    def __init__(self,
                 widget: QtWidgets.QWidget,
                 title: str = '',
                 parent: Optional[QtWidgets.QWidget] = None,
                 expanding: bool = True) -> None:
        """Constructor.

        :param widget: the widget we'd like to collapse.
        :param title: title of the widget. will appear on the toolbutton that
            we use to trigger collapse/expansion.
        :param parent: parent widget.
        """
        super().__init__(parent=parent)

        self.widget = widget
        self.widget.setParent(self)
        if expanding:
            setVExpanding(self.widget)

        self.expandedTitle = "[-] " + title
        self.collapsedTitle = "[+] " + title

        self.btn = QtWidgets.QPushButton(self.expandedTitle, parent=self)
        self.btn.setStyleSheet("""background: white; 
                                  color: black; 
                                  border: 2px solid white;
                                  text-align: left;""")
        self.btn.setFlat(True)
        self.btn.setCheckable(True)
        self.btn.setChecked(True)
        setHExpanding(self.btn)
        self.btn.clicked.connect(self._onButton)

        layout = QtWidgets.QVBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(2)
        layout.addWidget(self.btn)
        layout.addWidget(self.widget)
Exemplo n.º 29
0
    def __init__(self, parent: Optional[QtWidgets.QWidget] = None):
        """Constructor for :class:`.FigureMakerWidget`.

        :param parent: parent widget.
        """
        super().__init__(parent=parent)

        self.subPlots: List[PlotBase] = []

        self.title = QtWidgets.QLabel(parent=self)
        self.title.setAlignment(QtCore.Qt.AlignHCenter)

        self.split = QtWidgets.QSplitter(parent=self)
        self.split.setOrientation(QtCore.Qt.Vertical)

        layout = QtWidgets.QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(2)
        layout.addWidget(self.title)
        layout.addWidget(self.split)
        self.setLayout(layout)

        self.setTitle('')
Exemplo n.º 30
0
 def add(parent, name):
     item = self.find(parent, name)
     if item is None:
         item = QtWidgets.QTreeWidgetItem(parent, [name])
         if os.path.splitext(name)[-1] in self.fileExtensions:
             fnt = QtGui.QFont()
             item.setFont(0, fnt)
         else:
             pass
         if isinstance(parent, DataFileList):
             parent.addTopLevelItem(item)
         else:
             parent.addChild(item)
     return item