def _createToolWindow(self):
     window = qt.QMainWindow(parent=self.plot)
     # import done here rather than at module level to avoid circular import
     # FitWidget -> BackgroundWidget -> PlotWindow -> actions -> fit -> FitWidget
     from ...fit.FitWidget import FitWidget
     fit_widget = FitWidget(parent=window)
     window.setCentralWidget(fit_widget)
     fit_widget.guibuttons.DismissButton.clicked.connect(window.close)
     fit_widget.sigFitWidgetSignal.connect(self.handle_signal)
     self.fit_widget = fit_widget
     return window
Пример #2
0
def main():
    a = qt.QApplication([])

    mw = qt.QMainWindow()
    mw.show()

    tdd = getFitConfigDialog(mw, default={"a": 1})
    tdd.show()
    tdd.exec_()
    print("TabsDialogData result: ", tdd.result())
    print("TabsDialogData output: ", tdd.output)

    a.exec_()
Пример #3
0
    def _getFitWindow(self):
        self.xlabel = self.plot.getXAxis().getLabel()
        self.ylabel = self.plot.getYAxis().getLabel()
        self.xmin, self.xmax = self.plot.getXAxis().getLimits()

        histo = _getUniqueHistogram(self.plot)
        curve = _getUniqueCurve(self.plot)

        if histo is None and curve is None:
            # ambiguous case, we need to ask which plot item to fit
            isd = ItemsSelectionDialog(parent=self.plot, plot=self.plot)
            isd.setWindowTitle("Select item to be fitted")
            isd.setItemsSelectionMode(qt.QTableWidget.SingleSelection)
            isd.setAvailableKinds(["curve", "histogram"])
            isd.selectAllKinds()

            result = isd.exec_()
            if result and len(isd.getSelectedItems()) == 1:
                item = isd.getSelectedItems()[0]
            else:
                return
        elif histo is not None:
            # presence of a unique histo and no curve
            item = histo
        elif curve is not None:
            # presence of a unique or active curve
            item = curve

        self.legend = item.getLegend()

        if isinstance(item, Histogram):
            bin_edges = item.getBinEdgesData(copy=False)
            # take the middle coordinate between adjacent bin edges
            self.x = (bin_edges[1:] + bin_edges[:-1]) / 2
            self.y = item.getValueData(copy=False)
        # else take the active curve, or else the unique curve
        elif isinstance(item, Curve):
            self.x = item.getXData(copy=False)
            self.y = item.getYData(copy=False)

        # open a window with a FitWidget
        if self.fit_window is None:
            self.fit_window = qt.QMainWindow()
            # import done here rather than at module level to avoid circular import
            # FitWidget -> BackgroundWidget -> PlotWindow -> actions -> fit -> FitWidget
            from ...fit.FitWidget import FitWidget
            self.fit_widget = FitWidget(parent=self.fit_window)
            self.fit_window.setCentralWidget(self.fit_widget)
            self.fit_widget.guibuttons.DismissButton.clicked.connect(
                self.fit_window.close)
            self.fit_widget.sigFitWidgetSignal.connect(self.handle_signal)
            self.fit_window.show()
        else:
            if self.fit_window.isHidden():
                self.fit_window.show()
                self.fit_widget.show()
            self.fit_window.raise_()

        self.fit_widget.setData(self.x, self.y, xmin=self.xmin, xmax=self.xmax)
        self.fit_window.setWindowTitle("Fitting " + self.legend +
                                       " on x range %f-%f" %
                                       (self.xmin, self.xmax))
Пример #4
0
            else:
                qt.QTimer.singleShot(100, app.quit)

        def paintGL(self):
            gl.glClearColor(1., 0., 0., 0.)
            gl.glClear(gl.GL_COLOR_BUFFER_BIT)


    parser = argparse.ArgumentParser()
    parser.add_argument('major')
    parser.add_argument('minor')

    args = parser.parse_args(args=sys.argv[1:])

    app = qt.QApplication([])
    window = qt.QMainWindow(flags=
        qt.Qt.Window |
        qt.Qt.FramelessWindowHint |
        qt.Qt.NoDropShadowWindowHint |
        qt.Qt.WindowStaysOnTopHint)
    window.setAttribute(qt.Qt.WA_ShowWithoutActivating)
    window.move(0, 0)
    window.resize(3, 3)
    widget = _TestOpenGLWidget(version=(args.major, args.minor))
    window.setCentralWidget(widget)
    window.setWindowOpacity(0.04)
    window.show()

    qt.QTimer.singleShot(1000, app.quit)
    sys.exit(app.exec_())
Пример #5
0
        return True

    def disconnect(self):
        self.blockSignal = True
        try:
            self.signal.disconnect(self.signalReceived)
        except:
            pass
        try:
            self.sigDelayed.disconnect(self.slot)
        except:
            pass


if __name__ == '__main__':
    app = qt.QApplication([])
    win = qt.QMainWindow()
    spin = qt.QSpinBox()
    win.setCentralWidget(spin)
    win.show()

    def fn(*args):
        print("Raw signal:", args)

    def fn2(*args):
        print("Delayed signal:", args)

    spin.valueChanged.connect(fn)
    # proxy = proxyConnect(spin, QtCore.SIGNAL('valueChanged(int)'), fn)
    proxy = SignalProxy(spin.valueChanged, delay=0.5, slot=fn2)
Пример #6
0
 def setUp(self):
     """Create and show a main window"""
     self.window = qt.QMainWindow()
     self.qWaitForWindowExposed(self.window)