Exemplo n.º 1
0
def showInformation(message):
    """
    shows a information dialog with given message
    """

    guidata.qapplication().beep()
    QMessageBox.information(None, "Information", message)
Exemplo n.º 2
0
def showWarning(message):
    """
    shows a warning dialog with given message
    """


    guidata.qapplication().beep()
    QMessageBox.warning(None, "Warning", message)
Exemplo n.º 3
0
    def show(self):
        """ opens the constructed dialog.

            In order to do so we construct sublcass of DataSet on the fly.

            the docstring of the class is the title of the dialog,
            class level attributes are instances of sublcasses of
            DataItem, eg IntItem.

            For more info see the docs of guidata how those classes
            are declared to get the wanted dialog.

        """
        import guidata
        app = guidata.qapplication()

        # put the class level attributes in a dict
        attributes = dict(zip(self.fieldNames, self.items))
        # construct class "Dialog" which is a sublcass of "dt.DataSet"
        # with the  given attributes:
        clz = type("Dialog", (dt.DataSet, ), attributes)
        # as said: the docstring is rendered as the dialogues title:
        clz.__doc__ = self.title + "\n" + "\n".join(self.instructions)
        # open dialog now !!!
        instance = clz()
        if instance.edit() == 0:
            raise Exception("dialog aborted by user")
        # return the values a tuple according to the order of the
        # declared input widgets:
        result = [getattr(instance, name) for name in self.fieldNames]
        result = tuple(result)
        if len(result) == 1:
            result = result[0]
        return result
Exemplo n.º 4
0
def showInformation(message, title="Information"):
    """
    shows a information dialog with given message
    """

    app = guidata.qapplication()
    QMessageBox.information(None, title, message)
Exemplo n.º 5
0
def showWarning(message, title="Warning"):
    """
    shows a warning dialog with given message
    """

    app = guidata.qapplication()
    QMessageBox.warning(None, title, message)
Exemplo n.º 6
0
Arquivo: gui.py Projeto: BD75/mpsrad
def begin():
    app = qapplication()
    global window
    window = MainWindow()
    window.showMaximized()
    print('ok')
    return (app, window)
Exemplo n.º 7
0
def test():
    """Test"""
    # -- Create QApplication
    import guidata

    _app = guidata.qapplication()
    # --
    from numpy import linspace, sin, trapz

    x = linspace(-10, 10, 1000)
    y = sin(sin(sin(x)))

    curve = make.curve(x, y, "ab", "b")
    range = make.range(-2, 2)
    disp0 = make.range_info_label(range,
                                  "BR",
                                  "x = %.1f ± %.1f cm",
                                  title="Range infos")

    disp1 = make.computation(range, "BL", "trapz=%g", curve,
                             lambda x, y: trapz(y, x))

    disp2 = make.computations(
        range,
        "TL",
        [
            (curve, "min=%.5f", lambda x, y: y.min()),
            (curve, "max=%.5f", lambda x, y: y.max()),
            (curve, "avg=%.5f", lambda x, y: y.mean()),
        ],
    )
    legend = make.legend("TR")
    plot(curve, range, disp0, disp1, disp2, legend)
Exemplo n.º 8
0
 def save(self, fname, format, draft):
     if is_text_string(fname):
         if format == "pdf":
             self.app = guidata.qapplication()
             if draft:
                 mode = QPrinter.ScreenResolution
             else:
                 mode = QPrinter.HighResolution
             printer = QPrinter(mode)
             printer.setOutputFormat(QPrinter.PdfFormat)
             printer.setOrientation(QPrinter.Landscape)
             printer.setOutputFileName(fname)
             printer.setCreator('guiqwt.pyplot')
             self.print_(printer)
         else:
             if self.win is None:
                 self.show()
             if PYQT5:
                 pixmap = self.win.centralWidget().grab()
             else:
                 pixmap = QPixmap.grabWidget(self.win.centralWidget())
             pixmap.save(fname, format.upper())
     else:
         # Buffer
         fd = fname
         assert hasattr(fd, 'write'), "object is not file-like as expected"
         if self.win is None:
             self.show()
         pixmap = QPixmap.grabWidget(self.win.centralWidget())
         buff = QBuffer()
         buff.open(QIODevice.ReadWrite)
         pixmap.save(buff, format.upper())
         fd.write(buff.data())
         buff.close()
         fd.seek(0)
Exemplo n.º 9
0
def test():
    """Test"""
    # -- Create QApplication
    import guidata

    _app = guidata.qapplication()
    # --
    filename = osp.join(osp.dirname(__file__), "brain.png")
    image = make.image(filename=filename, title="Original", colormap="gray")

    win = ImageDialog(
        edit=False,
        toolbar=True,
        wintitle="Contrast test",
        options=dict(show_contrast=True),
    )
    plot = win.get_plot()
    plot.add_item(image)
    win.resize(600, 600)
    win.show()
    try:
        plot.save_widget("contrast.png")
    except IOError:
        # Skipping this part of the test
        # because user has no write permission on current directory
        pass
    win.exec_()
Exemplo n.º 10
0
def run():
    """Run benchmark"""
    # Print informations banner
    from guidata import qt
    import guiqwt
    qt_lib = {'pyqt': 'PyQt4', 'pyqt5': 'PyQt5', 'pyside': 'PySide'}[qt.API]
    title = "guiqwt plot benchmark [%s v%s (Qt v%s), guiqwt v%s]" %\
            (qt_lib, qt.__version__, qt.QtCore.__version__, guiqwt.__version__)
    print(title)
    print('-' * len(title))
    print()

    import guidata
    app = guidata.qapplication()

    # Run benchmarks
    close = True
    for benchmark in (
            CurveBM('Simple curve', 5e6),
            CurveBM('Curve with markers', 2e5, marker="Ellipse",
                    markersize=10),
            CurveBM('Curve with sticks', 1e6, curvestyle="Sticks"),
            ErrorBarBM('Error bar curve (vertical bars only)', 1e4),
            ErrorBarBM('Error bar curve (horizontal and vertical bars)',
                       1e4,
                       dx=True),
            HistogramBM('Simple histogram', 1e6, bins=1e5),
            PColorBM('Polar pcolor', 1e3),
            ImageBM('Simple image', 7e3, interpolation='antialiasing'),
    ):
        benchmark.start(close=close)
    if not close:
        app.exec_()
Exemplo n.º 11
0
def do_mainloop(mainloop):
    global _current_fig
    if not _current_fig:
        print("Warning: must create a figure before showing it", file=sys.stderr)
    elif mainloop:
        app = guidata.qapplication()
        app.exec_()
Exemplo n.º 12
0
def test():
    """Test"""
    # -- Create QApplication
    import guidata
    _app = guidata.qapplication()
    # --
    imshow(IMGFILE)
Exemplo n.º 13
0
def test():
    """Test"""
    # -- Create QApplication
    import guidata
    _app = guidata.qapplication()
    # --
    from numpy import linspace, sin
    
    mydescr = N.dtype([('Zeit', 'float'), ('T1', 'float'), ('T2', 'float'), ('T3', 'float'),('T4', 'float'),('T5', 'float'), ('T6', 'float'), ('T7', 'float'),('T8', 'float')])
    myrecarray = read_array('test.ASC', mydescr)

    x = myrecarray['Zeit']
    y = savitzky_golay(myrecarray['T1'], window_size=131, order=3)
    y2 = savitzky_golay(myrecarray['T2'], window_size=131, order=3)
    y3 = savitzky_golay(myrecarray['T3'], window_size=131, order=3)

    #x = linspace(-10, 10, 200)
    #dy = x/100.
    #y = sin(sin(sin(x)))    
    #x2 = linspace(-10, 10, 20)
    #y2 = sin(sin(sin(x2)))
    plot(make.curve(x, y, color="b"),
         make.curve(x, y2, color="g",),
         make.curve(x, y3, color="r"),
         make.label("Relative position <b>outside</b>",
                    (x[0], y[0]), (-10, -10), "BR"),
         make.label("Relative position <i>inside</i>",
                    (x[0], y[0]), (10, 10), "TL"),
         make.label("Absolute position", "R", (0,0), "R"),
         make.legend("TR"),
         )
Exemplo n.º 14
0
def test():
    """Test"""
    # -- Create QApplication
    import guidata

    _app = guidata.qapplication()
    # --
    from numpy import linspace, sin

    x = linspace(-10, 10, 200)
    dy = x / 100.0
    y = sin(sin(sin(x)))
    x2 = linspace(-10, 10, 20)
    y2 = sin(sin(sin(x2)))
    plot(
        [
            make.curve(x, y, color="b"),
            make.label(
                "Relative position <b>outside</b>", (x[0], y[0]), (-10, -10), "BR"
            ),
        ],
        [
            make.curve(x2, y2, color="g"),
        ],
        [
            make.curve(x, sin(2 * y), color="r"),
            make.label("Relative position <i>inside</i>", (x[0], y[0]), (10, 10), "TL"),
        ],
        [
            make.merror(x, y / 2, dy),
            make.label("Absolute position", "R", (0, 0), "R"),
            make.legend("TR"),
        ],
    )
Exemplo n.º 15
0
def showInformation(message, title="Information"):
    """
    shows a information dialog with given message
    """

    app = guidata.qapplication()
    QMessageBox.information(None, title, message)
Exemplo n.º 16
0
    def show(self):
        """ opens the constructed dialog.

            In order to d so we construct sublcass of DataSet on the fly.

            the docstring of the class is the title of the dialog,
            class level attributes are instances of sublcasses of
            DataItem, eg IntItem.

            For more info see the docs of guidata how those classes
            are declared to get the wanted dialog.

        """
        import guidata
        app = guidata.qapplication()

        # put the class level attributes in a dict
        attributes = dict(zip(self.fieldNames, self.items))
        # construct class "Dialog" which is a sublcass of "dt.DataSet"
        # with the  given attributes:
        clz = type("Dialog", (dt.DataSet,), attributes)
        # as said: the docstring is rendered as the dialogues title:
        clz.__doc__ = self.title+"\n"+"\n".join(self.instructions)
        # open dialog now !!!
        instance = clz()
        if instance.edit() == 0:
            raise Exception("dialog aborted by user")
        # return the values a tuple according to the order of the
        # declared input widgets:
        result = [getattr(instance, name) for name in self.fieldNames]
        result = tuple(result)
        if len(result) == 1:
            result = result[0]
        return result
Exemplo n.º 17
0
def run():
    """Run benchmark"""
    # Print informations banner
    from guidata import qt
    import guiqwt
    qt_lib = {'pyqt': 'PyQt4', 'pyqt5': 'PyQt5', 'pyside': 'PySide'}[qt.API]
    title = "guiqwt plot benchmark [%s v%s (Qt v%s), guiqwt v%s]" %\
            (qt_lib, qt.__version__, qt.QtCore.__version__, guiqwt.__version__)
    print(title)
    print('-'*len(title))
    print()

    import guidata
    app = guidata.qapplication()
    
    # Run benchmarks
    close = True
    for benchmark in (
          CurveBM('Simple curve', 5e6),
          CurveBM('Curve with markers', 2e5,
                  marker="Ellipse", markersize=10),
          CurveBM('Curve with sticks', 1e6,
                  curvestyle="Sticks"),
          ErrorBarBM('Error bar curve (vertical bars only)', 1e4),
          ErrorBarBM('Error bar curve (horizontal and vertical bars)', 1e4,
                     dx=True),
          HistogramBM('Simple histogram', 1e6, bins=1e5),
          PColorBM('Polar pcolor', 1e3),
          ImageBM('Simple image', 7e3, interpolation='antialiasing'),
                     ):
        benchmark.start(close=close)
    if not close:
        app.exec_()
Exemplo n.º 18
0
Arquivo: fit.py Projeto: gyenney/Tools
def guifit(x,
           y,
           fitfunc,
           fitparams,
           fitargs=None,
           fitkwargs=None,
           wintitle=None,
           title=None,
           xlabel=None,
           ylabel=None,
           param_cols=1,
           auto_fit=True,
           winsize=None,
           winpos=None):
    """GUI-based curve fitting tool"""
    _app = guidata.qapplication()
    #    win = FitWidget(wintitle=wintitle, toolbar=True,
    #                    param_cols=param_cols, auto_fit=auto_fit,
    #                    options=dict(title=title, xlabel=xlabel, ylabel=ylabel))
    win = FitDialog(edit=True,
                    wintitle=wintitle,
                    toolbar=True,
                    param_cols=param_cols,
                    auto_fit=auto_fit,
                    options=dict(title=title, xlabel=xlabel, ylabel=ylabel))
    win.set_data(x, y, fitfunc, fitparams, fitargs, fitkwargs)
    if winsize is not None:
        win.resize(*winsize)
    if winpos is not None:
        win.move(*winpos)
    if win.exec_():
        return win.get_values()
Exemplo n.º 19
0
def do_mainloop(mainloop):
    global _current_fig
    if not _current_fig:
        print("Warning: must create a figure before showing it", file=sys.stderr)
    elif mainloop:
        app = guidata.qapplication()
        app.exec_()
Exemplo n.º 20
0
def test():
    """Test"""
    # -- Create QApplication
    import guidata
    _app = guidata.qapplication()
    # --
    imshow(IMGFILE)
Exemplo n.º 21
0
def test():
    """Test"""
    # -- Create QApplication
    import guidata
    _app = guidata.qapplication()
    # --
    # from numpy import linspace, sin
    #x = linspace(-10, 10, 200)

    start_rec = 819
    num_rec = 10000

    x = range(start_rec, start_rec + num_rec)
    vname, y = loadBinData('ATOLOG_01R_1.atp', start_rec, num_rec)
    plot(make.curve(x, y[0], title=vname[0], color="b"),
         make.curve(x, y[1], title=vname[1], color="g"),
         #make.curve(x, sin(2*y), color="r"),
         #make.merror(x, y/2, dy),
         #make.label("Relative position <b>outside</b>",
         #           (x[0], y[0]), (-10, -10), "BR"),
         #make.label("Relative position <i>inside</i>",
         #           (x[0], y[0]), (10, 10), "TL"),
         #make.label("Absolute position", "R", (0,0), "R"),
         make.legend("TR"),
         #make.marker(position=(5., .8), label_cb=lambda x, y: u"A = %.2f" % x,
         #            markerstyle="|", movable=False)
         )
Exemplo n.º 22
0
 def change_defaults(self):
     """ Allow the user to change the default settings """
     
     # Create QApplication
     import guidata
     _app = guidata.qapplication()
     
     e = DefaultParameters()
     print(e)
     if e.edit():
         defaults = {
         'accLim': e.acc_limit,
         'gyrLim': e.gyr_limit,
         'dataDir': e.data_dir,
         'topColor': e.color_top,
         'middleColor': e.color_middle,
         'bottomColor': e.color_bottom,
         'upper_thresh': e.upper_thresh,
         'lower_thresh': e.lower_thresh,
         'init_channel': e.init_channel,
         'opening_view': e.opening_view
         }
         settings_file = 'settings.yaml'
         with open(settings_file, 'w') as fh:
             yaml.dump(defaults, fh)
         print(f'New settings saved to {settings_file}')
         print(e)
Exemplo n.º 23
0
def test():
    """Test"""
    # -- Create QApplication
    import guidata

    _app = guidata.qapplication()
    # --
    from numpy import linspace, sin, trapz

    x = linspace(-10, 10, 1000)
    y = sin(sin(sin(x)))

    curve = make.curve(x, y, "ab", "b")
    range = make.range(-2, 2)
    disp0 = make.range_info_label(range, "BR", "x = %.1f ± %.1f cm", title="Range infos")

    disp1 = make.computation(range, "BL", "trapz=%g", curve, lambda x, y: trapz(y, x))

    disp2 = make.computations(
        range,
        "TL",
        [
            (curve, "min=%.5f", lambda x, y: y.min()),
            (curve, "max=%.5f", lambda x, y: y.max()),
            (curve, "avg=%.5f", lambda x, y: y.mean()),
        ],
    )
    legend = make.legend("TR")
    plot(curve, range, disp0, disp1, disp2, legend)
Exemplo n.º 24
0
def test():
    """Test"""
    # -- Create QApplication
    import guidata

    _app = guidata.qapplication()
    # --
    from numpy import linspace, sin

    x = linspace(-10, 10, 200)
    dy = x / 100.0
    y = sin(sin(sin(x)))
    x2 = linspace(-10, 10, 20)
    y2 = sin(sin(sin(x2)))
    curve2 = make.curve(x2, y2, color="g", curvestyle="Sticks")
    curve2.setTitle("toto")
    plot(
        make.curve(x, y, color="b"),
        curve2,
        make.curve(x, sin(2 * y), color="r"),
        make.merror(x, y / 2, dy),
        make.label("Relative position <b>outside</b>", (x[0], y[0]), (-10, -10), "BR"),
        make.label("Relative position <i>inside</i>", (x[0], y[0]), (10, 10), "TL"),
        make.label("Absolute position", "R", (0, 0), "R"),
        make.legend("TR"),
        make.marker(position=(5.0, 0.8), label_cb=lambda x, y: "A = %.2f" % x, markerstyle="|", movable=False),
    )
Exemplo n.º 25
0
def ProgressBar(n_steps, label="", allow_cancel=False, parent=None):
    """
    Progressbar context manager for showing progress of workflow to user. Example::

        with emzed.gui.ProgressBar(n_steps=100, allow_cancel=True) as handler:
            for i in range(100):

                # we simulate work of step i

                # we update progressbar
                handler.update(i, "step %03d" % i)

                # we can check if user pressed "Cancel" button and stop our "workflow":
                if handler.is_canceled():
                    break
    """

    app = guidata.qapplication()
    dlg = QProgressDialog(parent)
    dlg.setLabelText(label)
    dlg.setAutoClose(False)
    dlg.setAutoReset(False)
    if allow_cancel:
        dlg.setCancelButtonText("Cancel")
    dlg.setMaximum(n_steps)

    class ProgressBarHandler(object):
        def __init__(self, n_steps, dlg):
            self._dlg = dlg
            self._n_steps = n_steps
            self._n = 0
            self._canceled = False
            dlg.canceled.connect(self._set_canceled)
            dlg.setValue(0)

        def _set_canceled(self):
            self._canceled = True
            dlg.close()

        def update(self, n, message=None):
            app.processEvents()
            self._n = n
            dlg.setValue(n + 1)
            if message is not None:
                dlg.setLabelText(message)
            dlg.update()
            app.processEvents()

        def is_canceled(self):
            return self._canceled

    dlg.activateWindow()
    dlg.show()
    dlg.raise_()
    app.processEvents()

    handler = ProgressBarHandler(n_steps, dlg)
    yield handler

    dlg.close()
Exemplo n.º 26
0
 def save(self, fname, format, draft):
     if is_text_string(fname):
         if format == "pdf":
             self.app = guidata.qapplication()
             if draft:
                 mode = QPrinter.ScreenResolution
             else:
                 mode = QPrinter.HighResolution
             printer = QPrinter(mode)
             printer.setOutputFormat(QPrinter.PdfFormat)
             printer.setOrientation(QPrinter.Landscape)
             printer.setOutputFileName(fname)
             printer.setCreator('guiqwt.pyplot')
             self.print_(printer)
         else:
             if self.win is None:
                 self.show()
             if PYQT5:
                 pixmap = self.win.centralWidget().grab()
             else:
                 pixmap = QPixmap.grabWidget(self.win.centralWidget())
             pixmap.save(fname, format.upper())
     else:
         # Buffer
         fd = fname
         assert hasattr(fd, 'write'), "object is not file-like as expected"
         if self.win is None:
             self.show()
         pixmap = QPixmap.grabWidget(self.win.centralWidget())
         buff = QBuffer()
         buff.open(QIODevice.ReadWrite)
         pixmap.save(buff, format.upper())
         fd.write(buff.data())
         buff.close()
         fd.seek(0)
Exemplo n.º 27
0
def inspectPeakMap(peakmap,
                   peakmap2=None,
                   table=None,
                   modal=True,
                   parent=None,
                   rtmin=None,
                   rtmax=None,
                   mzmin=None,
                   mzmax=None):
    """
    allows the visual inspection of a peakmap
    """

    peakmap = peakmap.cleaned()

    if len(peakmap) == 0:
        raise Exception("empty peakmap")

    app = guidata.qapplication()  # singleton !
    ok_rows = []
    win = PeakMapExplorer(ok_rows, parent=parent)
    win.setup(peakmap, peakmap2, table)

    if modal:
        win.raise_()
        win.exec_()
        return ok_rows
    else:
        win.show()

    return ok_rows
Exemplo n.º 28
0
def test():
    """Test"""
    # -- Create QApplication
    import guidata

    _app = guidata.qapplication()
    # --
    from numpy import linspace, sin

    x = linspace(-10, 10, 200)
    dy = x / 100.0
    y = sin(sin(sin(x)))
    x2 = linspace(-10, 10, 20)
    y2 = sin(sin(sin(x2)))
    curve2 = make.curve(x2, y2, color="g", curvestyle="Sticks")
    curve2.setTitle("toto")
    plot(
        make.curve(x, y, color="b"),
        curve2,
        make.curve(x, sin(2 * y), color="r"),
        make.merror(x, y / 2, dy),
        make.label("Relative position <b>outside</b>", (x[0], y[0]),
                   (-10, -10), "BR"),
        make.label("Relative position <i>inside</i>", (x[0], y[0]), (10, 10),
                   "TL"),
        make.label("Absolute position", "R", (0, 0), "R"),
        make.legend("TR"),
        make.marker(
            position=(5.0, 0.8),
            label_cb=lambda x, y: "A = %.2f" % x,
            markerstyle="|",
            movable=False,
        ),
    )
Exemplo n.º 29
0
def do_app(): #todo remove
	app = qapplication()
	mydialog = MyFilePicker()
	if mydialog.edit():
		print(mydialog.to_string())
		mydialog.view()
	return mydialog.files
Exemplo n.º 30
0
def test():
    """Test"""
    # -- Create QApplication
    import guidata
    _app = guidata.qapplication()
    # --    
    imshow(*compute_image())
Exemplo n.º 31
0
def inspect(what,
            offerAbortOption=False,
            modal=True,
            parent=None,
            close_callback=None):
    """
    allows the inspection and editing of simple or multiple
    tables.

    """
    if isinstance(what, (Table, Hdf5TableProxy)):
        what = [what]
    app = guidata.qapplication()  # singleton !
    explorer = TableExplorer(what,
                             offerAbortOption,
                             parent=parent,
                             close_callback=close_callback)
    if modal:
        explorer.raise_()
        explorer.exec_()
        # partial cleanup
        modified = len(explorer.models[0].actions) > 0
        del explorer.models
        if offerAbortOption:
            if explorer.result == 1:
                raise Exception("Dialog aborted by user")
        return modified
    else:
        explorer.show()
    del app
Exemplo n.º 32
0
def showWarning(message, title="Warning"):
    """
    shows a warning dialog with given message
    """

    app = guidata.qapplication()
    QMessageBox.warning(None, title, message)
Exemplo n.º 33
0
def test():
    """Test"""
    # -- Create QApplication
    import guidata
    _app = guidata.qapplication()
    # --
    items = compute_quads()+compute_quads3()
    imshow(items)
Exemplo n.º 34
0
def test():
    """Test"""
    # -- Create QApplication
    import guidata
    _app = guidata.qapplication()
    # --
    items = compute_quads() + compute_quads3()
    imshow(items)
Exemplo n.º 35
0
def _findParametersManually(tobe, real):
    import guidata
    app = guidata.qapplication()
    m = _MatchSelector(tobe, real)
    m.raise_()
    m.exec_()
    if m.exitCode != 0:
        return None, None
    return m.transform, (m.real, m.tobe)
Exemplo n.º 36
0
def _findParametersManually(tobe, real):
    import guidata
    app = guidata.qapplication()
    m = _MatchSelector(tobe, real)
    m.raise_()
    m.exec_()
    if m.exitCode != 0:
        return None, None
    return m.transform, (m.real, m.tobe)
Exemplo n.º 37
0
def test():
    """Test"""
    # -- Create QApplication
    import guidata
    _app = guidata.qapplication()
    # --
    from numpy import linspace, sin
    import labrad
    cx=labrad.connect('lab-rat', password='******')
    ai=cx.agilent_pna
    ai.select_device(0)
    ai.s_parameters(['S21'])
    ai.averages(1000)
    ai.bandwidth(100)
    ai.power(0)
    ai.frequency_range(10.93e9, 11.03e9)
    ai.num_points(3201)
    testscan=ai.freq_sweep()
    print len(testscan)
    xx=testscan[0].asarray
    print xx
    yytemp=testscan[1].asarray[0]
    print yytemp
    yy=np.square(np.abs(yytemp))
#    x = linspace(-10, 10, 200)
#    dy = x/100.
#    y = sin(sin(sin(x)))    
#    x2 = linspace(-10, 10, 20)
#    y2 = sin(sin(sin(x2)))
#    plot(make.curve(x, y, color="b"),
#         make.curve(x2, y2, color="g", curvestyle="Sticks"),
#         make.curve(x, sin(2*y), color="r"),
#         make.merror(x, y/2, dy),
#         make.label("Relative position <b>outside</b>",
#                    (x[0], y[0]), (-10, -10), "BR"),
#         make.label("Relative position <i>inside</i>",
#                    (x[0], y[0]), (10, 10), "TL"),
#         make.label("Absolute position", "R", (0,0), "R"),
#         make.legend("TR"),
#         make.marker(position=(5., .8), label_cb=lambda x, y: u"A = %.2f" % x,
#                     markerstyle="|", movable=False)
#         )
    plot(make.curve(xx*1e-9, 10*np.log10(yy), color="b")#,
#         make.curve(xx*2e-9, 10*np.log10(yy), color="g"),
#         make.curve(x, sin(2*y), color="r"),
#         make.merror(x, y/2, dy),
#         make.label("PNA SCAN<b>test</b>",
#                    (xx[0], yy[0]), (-10, -10), "BR"),
#         make.label("PNA SCAN<b>test 2X</b>",
#                    (xx[0], yy[0]), (-10, -10), "BR"),
#         make.label("Relative position <i>inside</i>",
#                    (x[0], y[0]), (10, 10), "TL"),
#         make.label("Absolute position", "R", (0,0), "R"),
#         make.legend("TR")
#         make.marker(position=(5., .8), label_cb=lambda xx, yy: u"A = %.2f" % xx,
#                     markerstyle="|", movable=False)
         )
Exemplo n.º 38
0
def test():
    """Test"""
    # -- Create QApplication
    import guidata
    app = guidata.qapplication()
    # --    
    win = Window()
    win.show()
    app.exec_()
Exemplo n.º 39
0
def test():
    """Test"""
    # -- Create QApplication
    import guidata
    _app = guidata.qapplication()
    # --
    for func in (compute_image, compute_image_2, compute_image_3):
        img = func()
        print(img.dtype)
        imshow(img)
Exemplo n.º 40
0
def saveCalibrationPickle(stereo_var,calib_var):
    
    print '\n# SAVE CALIBRATION'
    # save data to file    
    app = guidata.qapplication()

    # get selected directory
    myDir = getexistingdirectory()
    with open(myDir+'\calibration.pickle', 'w') as f:
        pickle.dump([stereo_var,calib_var], f)
Exemplo n.º 41
0
 def build_window(self):
     self.app = guidata.qapplication()
     self.win = Window(wintitle=self.title)
     images = False
     for (i, j), ax in list(self.axes.items()):
         ax.setup_window(i, j, self.win)
         if ax.images:
             images = True
     self.win.add_panels(images=images)
     self.win.register_tools(images=images)
Exemplo n.º 42
0
def run():
    from guidata import qapplication
    app = qapplication()
    w = ThothMainWindow()
    app.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()"))

    app.connect(w, SIGNAL("closed()"), app, SLOT("quit()"))

    w.show()
    app.exec_()
Exemplo n.º 43
0
 def build_window(self):
     self.app = guidata.qapplication()
     self.win = Window(wintitle=self.title)
     images = False
     for (i, j), ax in list(self.axes.items()):
         ax.setup_window(i, j, self.win)
         if ax.images:
             images = True
     self.win.add_panels(images=images)
     self.win.register_tools(images=images)
Exemplo n.º 44
0
    def eic_plotter(self):
        """generator which receives plot items"""

        unique_labels = set()
        seen = set()
        allrts = []

        for i in itertools.count():

            item = yield

            if item is None:
                break

            label, curve, config = item

            if config is None:
                config = {"color": getColor(i), "linewidth": 1.5}

            rts, chromatogram = curve
            if (id(rts), id(chromatogram)) in seen:
                continue
            seen.add((id(rts), id(chromatogram)))
            label = "<pre>%s</pre>" % label
            unique_labels.add(label)
            curve = make_unselectable_curve(rts, chromatogram, title=label, **config)
            allrts.extend(rts)
            self.plot.add_item(curve)
            self.plot.replot()
            qapplication().processEvents()

        self.plot.add_item(self.label)
        self.plot.set_x_values(sorted(set(allrts)))
        # no idea why guiqwt needs double registration here:
        self.marker.attach(self.plot)
        self.plot.add_item(self.marker)

        if self.range_ is not None:
            self.plot.add_item(self.range_)
        self.plot.replot()

        yield  # avoids StopIteration
Exemplo n.º 45
0
 def setData(self, index, value, role=Qt.EditRole):
     assert isinstance(value, QVariant)
     if index.isValid() and 0 <= index.row() < len(self.table):
         dataIdx = self.widgetColToDataCol[index.column()]
         expectedType = self.table._colTypes[dataIdx]
         if value.toString().trimmed()=="-":
             value = None
         elif expectedType != object:
             # QVariant -> QString -> str + strip:
             value = str(value.toString()).strip()
             # minutes ?
             if re.match("^((\d+m)|(\d*.\d+m))$", value):
                 value = 60.0 * float(value[:-1])
             try:
                 value = expectedType(value)
             except Exception:
                 guidata.qapplication().beep()
                 return False
         return self.runAction(ChangeValueAction, index, dataIdx, value)
     return False
Exemplo n.º 46
0
def test():
    """Test"""
    # -- Create QApplication
    import guidata
    _app = guidata.qapplication()
    # --
    filename = osp.join(osp.dirname(__file__), "brain.png")
    image = make.image(filename=filename, colormap="bone")
    rect = get_segment(image)
    print("Coordinates:", rect)
    print("Distance:", np.sqrt((rect[2]-rect[0])**2 + (rect[3]-rect[1])**2))
Exemplo n.º 47
0
 def setData(self, index, value, role=Qt.EditRole):
     assert isinstance(value, QVariant)
     if index.isValid() and 0 <= index.row() < len(self.table):
         __, dataIdx = self.table_index(index)
         expectedType = self.table._colTypes[dataIdx]
         if value.toString().trimmed() == "-":
             value = None
         elif expectedType != object:
             # QVariant -> QString -> str + strip:
             value = str(value.toString()).strip()
             # minutes ?
             if re.match("^((\d+m)|(\d*.\d+m))$", value):
                 value = 60.0 * float(value[:-1])
             try:
                 value = expectedType(value)
             except Exception:
                 guidata.qapplication().beep()
                 return False
         return self.runAction(ChangeValueAction, index, dataIdx, value)
     return False
Exemplo n.º 48
0
def chooseConfig(configs, params):

    from config_choose_dialog import ConfigChooseDialog
    import guidata

    app = guidata.qapplication()
    dlg = ConfigChooseDialog(configs, params)
    dlg.activateWindow()
    dlg.raise_()
    dlg.exec_()

    return dlg.result
Exemplo n.º 49
0
def chooseConfig(configs, params):

    from config_choose_dialog import ConfigChooseDialog
    import guidata

    app = guidata.qapplication()
    dlg = ConfigChooseDialog(configs, params)
    dlg.activateWindow()
    dlg.raise_()
    dlg.exec_()

    return dlg.result
Exemplo n.º 50
0
def loadCalibrationPickle():
    
    print '\n# LOAD CALIBRATION'
    # save data to file    
    app = guidata.qapplication()

    # get selected directory
    myDir = getexistingdirectory()
    with open(myDir+'\calibration.pickle') as f:
        stereo_var,calib_var = pickle.load(f)
    
    return stereo_var,calib_var
Exemplo n.º 51
0
def test():
    """Test"""
    # -- Create QApplication
    import guidata
    _app = guidata.qapplication()
    # --
    filename = osp.join(osp.dirname(__file__), "brain.png")
    win = create_window()
    image = make.image(filename=filename, colormap="bone", alpha_mask=True)
    plot = win.get_plot()
    plot.add_item(image)
    win.exec_()
Exemplo n.º 52
0
def test():
    """Test"""
    # -- Create QApplication
    import guidata
    _app = guidata.qapplication()
    # --
    from numpy import linspace, sin
    x = linspace(-10, 10, 1000)
    y = sin(sin(sin(x)))
    x2 = linspace(-10, 10, 20)
    y2 = sin(sin(sin(x2)))
    print(get_point((x, y), (x2, y2), (x, sin(2 * y))))
Exemplo n.º 53
0
def test():
    """Test"""
    # -- Create QApplication
    import guidata
    _app = guidata.qapplication()
    # --
    from numpy import linspace, sin
    x = linspace(-10, 10, 1000)
    y = sin(sin(sin(x)))    
    x2 = linspace(-10, 10, 20)
    y2 = sin(sin(sin(x2)))
    print(get_point( (x, y), (x2, y2), (x, sin(2*y)) ))
Exemplo n.º 54
0
def inspectPeakMap(peakmap, peakmap2=None, extra_items=None, table=None, modal=True, parent=None):
    """
    allows the visual inspection of a peakmap
    """

    app = guidata.qapplication()  # singleton !
    win = PeakMapExplorer(parent=parent)
    win.setup(peakmap, peakmap2, extra_items)
    if modal:
        win.raise_()
        win.exec_()
    else:
        win.show()
Exemplo n.º 55
0
    def editConfig(self):
        import guidata

        app = guidata.qapplication() # singleton !

        import guidata.dataset.datatypes as dt
        import guidata.dataset.dataitems as di

        def check_value(self, value):
            if not isinstance(value, self.type):
                return False
            if str(value).strip()=="":
                return True
            return di.DirectoryItem._check_value(self, value)

        di.DirectoryItem._check_value = di.DirectoryItem.check_value
        di.DirectoryItem.check_value = check_value
        class ConfigEditor(dt.DataSet):
            """ ConfigEditor

                Please provide a global exchange folder for databases,
                scripts and configs shared among your lab.

                If you do not have such an exchange folder, leave the
                field empty.

                You need a metlin token for accessing the metlin
                web service. To register for this token go to

                    http://metlin.scripps.edu/soap/register.php

                You can leave this field empty.

                If you want to modify these values later, enter

                >>> import userConfig
                >>> userConfig.setMetlinToken("....")

            """
            exchangeFolder = di.DirectoryItem("Global exchange folder:",
                    notempty=False, default=self.exchangeFolder or "")
            metlinToken = di.StringItem("Metlin token:",
                    default = self.metlinToken or "")

        dlg = ConfigEditor()
        dlg.edit()
        self.exchangeFolder = dlg.exchangeFolder
        self.metlinToken = dlg.metlinToken
        di.DirectoryItem.check_value = di.DirectoryItem._check_value
        self.saveConfig()