Exemplo n.º 1
0
 def _update_label(self, pause=None):
     if pause is None:
         pause = qt.flow.is_paused()
     if pause:
         self.set_label(_L('Continue'))
     else:
         self.set_label(_L('Pause'))
Exemplo n.º 2
0
    def _add_parameters(self):
        rows = 0
        parameters = self._instrument.get_shared_parameters()
        for name, opts in dict_to_ordered_tuples(parameters):
            self._table.resize(rows + 1, 2)

            label = gtk.Label(name)
            self._table.attach(label, 0, 1, rows, rows + 1)

            entry = self._create_entry(name, opts)
            self._table.attach(entry, 1, 2, rows, rows + 1)

            self._param_info[name] = {
                'entry': entry,
                'flags': opts['flags'],
            }

            hbox = gtk.HBox()
            if opts['flags'] & qt.constants.FLAG_SET:
                but = gtk.Button(_L('Set'))
                but.connect('clicked', self._set_clicked, name)
                if not isinstance(entry, ComboEntry) and not isinstance(entry, MultiStringEntry):
                    entry.connect('activate', self._set_clicked, name)                
                hbox.pack_start(but)
            if opts['flags'] & qt.constants.FLAG_GET or \
                    opts['flags'] & qt.constants.FLAG_SOFTGET:
                but = gtk.Button(_L('Get'))
                but.connect('clicked', self._get_clicked, name)
                hbox.pack_start(but)

            self._table.attach(hbox, 2, 3, rows, rows + 1)
            rows += 1
    def create_layout(self):
        self._frame = gtk.Frame()
        if self._label is not None:
            self._frame.set_label(self._label)

        self._vbox = gtk.VBox(spacing=4)
        self._vbox.set_border_width(4)

        self._variable_dropdown = AllParametersDropdown(
                                    flags=qt.constants.FLAG_GET,
                                    types=(types.IntType, types.FloatType),
                                    tags=['measure'])
        self._variable_dropdown.connect('changed', self._parameter_changed_cb)
        self._vbox.pack_start(gui.pack_hbox([
            gtk.Label(_L('Measurement variable')),
            self._variable_dropdown]), False, False)

        self._scale = gtk.Entry()
        self._scale.set_width_chars(12)
        self._scale.set_text('1')
        self._units = gtk.Entry()
        self._units.set_width_chars(12)

        self._vbox.pack_start(gui.pack_hbox([
            gtk.Label(_L('Scaling')),
            self._scale,
            gtk.Label(_L('Units')),
            self._units]))

        self._frame.add(self._vbox)
Exemplo n.º 4
0
    def _add_parameters(self):
        rows = 0
        parameters = self._instrument.get_shared_parameters()
        for name, opts in dict_to_ordered_tuples(parameters):
            self._table.resize(rows + 1, 2)

            label = gtk.Label(name)
            self._table.attach(label, 0, 1, rows, rows + 1)

            entry = self._create_entry(name, opts)
            self._table.attach(entry, 1, 2, rows, rows + 1)

            self._param_info[name] = {
                'entry': entry,
                'flags': opts['flags'],
            }

            hbox = gtk.HBox()
            if opts['flags'] & qt.constants.FLAG_SET:
                but = gtk.Button(_L('Set'))
                but.connect('clicked', self._set_clicked, name)
                if not isinstance(entry, ComboEntry):
                   entry.connect('activate', self._set_clicked, name)
                hbox.pack_start(but)
            if opts['flags'] & qt.constants.FLAG_GET or \
                    opts['flags'] & qt.constants.FLAG_SOFTGET:
                but = gtk.Button(_L('Get'))
                but.connect('clicked', self._get_clicked, name)
                hbox.pack_start(but)

            self._table.attach(hbox, 2, 3, rows, rows + 1)
            rows += 1
Exemplo n.º 5
0
    def create_layout(self):
        self._frame = gtk.Frame()
        if self._label is not None:
            self._frame.set_label(self._label)

        self._vbox = gtk.VBox(spacing=4)
        self._vbox.set_border_width(4)

        self._variable_dropdown = AllParametersDropdown(
            flags=qt.constants.FLAG_GET,
            types=(types.IntType, types.FloatType),
            tags=['measure'])
        self._variable_dropdown.connect('changed', self._parameter_changed_cb)
        self._vbox.pack_start(
            gui.pack_hbox([
                gtk.Label(_L('Measurement variable')), self._variable_dropdown
            ]), False, False)

        self._scale = gtk.Entry()
        self._scale.set_width_chars(12)
        self._scale.set_text('1')
        self._units = gtk.Entry()
        self._units.set_width_chars(12)

        self._vbox.pack_start(
            gui.pack_hbox([
                gtk.Label(_L('Scaling')), self._scale,
                gtk.Label(_L('Units')), self._units
            ]))

        self._frame.add(self._vbox)
Exemplo n.º 6
0
    def _add_parameters(self):
        rows = 0
        parameters = self._instrument.get_shared_parameters()
        for name, opts in dict_to_ordered_tuples(parameters):
            self._table.resize(rows + 1, 2)

            label = gtk.Label(name)
            self._table.attach(label, 0, 1, rows, rows + 1)

            entry = self._create_entry(name, opts)
            self._table.attach(entry, 1, 2, rows, rows + 1)

            self._param_info[name] = {"entry": entry, "flags": opts["flags"]}

            hbox = gtk.HBox()
            if opts["flags"] & qt.constants.FLAG_SET:
                if "units" in opts:
                    unitlabel = gtk.Label(opts["units"])
                    self._table.attach(unitlabel, 2, 3, rows, rows + 1)
                but = gtk.Button(_L("Set"))
                but.connect("clicked", self._set_clicked, name)
                if not isinstance(entry, ComboEntry):
                    entry.connect("activate", self._set_clicked, name)
                hbox.pack_start(but)
            if opts["flags"] & qt.constants.FLAG_GET or opts["flags"] & qt.constants.FLAG_SOFTGET:
                but = gtk.Button(_L("Get"))
                but.connect("clicked", self._get_clicked, name)
                hbox.pack_start(but)

            self._table.attach(hbox, 3, 4, rows, rows + 1)
            rows += 1
Exemplo n.º 7
0
 def _update_label(self, pause=None):
     if pause is None:
         pause = qt.flow.is_paused()
     if pause:
         self.set_label(_L('Continue'))
     else:
         self.set_label(_L('Pause'))
Exemplo n.º 8
0
    def __init__(self, **kwargs):
        gtk.VBox.__init__(self, **kwargs)

        self._frontpanels = qt.frontpanels
        self._sliders = qt.sliders

        self._ins = None
        self._ins_combo = dropdowns.InstrumentDropdown()
        self._ins_combo.connect('changed', self._instrument_changed_cb)

        self._param_combo = dropdowns.InstrumentParameterDropdown()
        self._param_combo.connect('changed', self._parameter_changed_cb)

        self._get_but = gtk.Button('Get')
        self._get_but.connect('clicked', self._get_param_clicked_cb)
        self._param_edit = gtk.Entry()
        self._param_edit.set_alignment(0.93)
        self._set_but = gtk.Button('Set')
        self._set_but.connect('clicked', self._set_param_clicked_cb)
        param_getset = gui.pack_hbox([self._get_but, \
                self._set_but])

        self._function_frame = FunctionFrame()

        self._make_fp = gtk.Button('Frontpanel')
        self._make_fp.connect('clicked', self._fp_clicked_cb)

        self._make_sl = gtk.Button('Slider')
        self._make_sl.connect('clicked', self._slider_clicked_cb)

        h1 = gui.pack_hbox([
            gtk.Label(_L('Instrument')),
            self._ins_combo])
        h2 = gui.pack_hbox([
            gtk.Label(_L('Parameter')),
            self._param_combo])

        self._table = gtk.Table(4, 2, True)
        self._table.set_homogeneous(False)

        self._table.attach(h1, 0, 1, 0, 1)
        self._table.attach(h2, 0, 1, 1, 2)
        self._table.attach(self._param_edit, 0, 1, 2, 3)
        self._table.attach(self._function_frame, 0, 2, 3, 4)

        self._table.attach(self._make_fp, 1, 2, 0, 1)
        self._table.attach(self._make_sl, 1, 2, 1, 2)
        self._table.attach(param_getset, 1, 2, 2, 3)

        self._table.set_border_width(4)
        self.add(self._table)

        self._parameter_changed_cb(None)
        self.show_all()
Exemplo n.º 9
0
    def __init__(self):
        qtwindow.QTWindow.__init__(self, 'instruments', 'Instrument View')

        self.connect("delete-event", self._delete_event_cb)

        self._instruments = qt.instruments

        qt.instruments.connect('instrument-added', self._instrument_added_cb)
        qt.instruments.connect('instrument-removed', \
            self._instrument_removed_cb)
        qt.instruments.connect('instrument-changed', \
            self._instrument_changed_cb)

        self._tags_dropdown = dropdowns.TagsDropdown()
        self._tags_dropdown.connect('changed', self._tag_changed_cb)

        self._outer_vbox = gtk.VBox()
        self._outer_vbox.set_border_width(4)
        self._vbox = gtk.VBox()
        self._vbox.set_border_width(4)

        self._outer_vbox.pack_start(
            gui.pack_hbox([gtk.Label(_L('Types')), self._tags_dropdown]),
            False, False)

        self._range_toggle = gtk.ToggleButton(_L('Range'))
        self._range_toggle.set_active(
            qt.config.get('Instrument View_show_range', True))
        self._range_toggle.connect('toggled', self._range_toggled_cb)
        self._rate_toggle = gtk.ToggleButton(_L('Rate'))
        self._rate_toggle.set_active(
            qt.config.get('Instrument View_show_rate', True))
        self._rate_toggle.connect('toggled', self._rate_toggled_cb)

        self._outer_vbox.pack_start(
            gui.pack_hbox([self._range_toggle, self._rate_toggle], True, True),
            False, False)

        self._ins_widgets = {}
        self._add_instruments()

        self._scrolled_win = gtk.ScrolledWindow()
        self._scrolled_win.set_policy(gtk.POLICY_AUTOMATIC, \
            gtk.POLICY_AUTOMATIC)
        self._scrolled_win.add_with_viewport(self._vbox)

        self._outer_vbox.pack_start(self._scrolled_win, True, True)

        self._outer_vbox.show_all()
        self._range_toggle.emit('toggled')
        self._rate_toggle.emit('toggled')
        self.add(self._outer_vbox)
    def __init__(self):
        qtwindow.QTWindow.__init__(self, 'instruments', 'Instrument View')

        self.connect("delete-event", self._delete_event_cb)

        self._instruments = qt.instruments

        qt.instruments.connect('instrument-added', self._instrument_added_cb)
        qt.instruments.connect('instrument-removed', \
            self._instrument_removed_cb)
        qt.instruments.connect('instrument-changed', \
            self._instrument_changed_cb)

        self._tags_dropdown = dropdowns.TagsDropdown()
        self._tags_dropdown.connect('changed', self._tag_changed_cb)

        self._outer_vbox = gtk.VBox()
        self._outer_vbox.set_border_width(4)
        self._vbox = gtk.VBox()
        self._vbox.set_border_width(4)

        self._outer_vbox.pack_start(gui.pack_hbox([
            gtk.Label(_L('Types')),
            self._tags_dropdown]), False, False)

        self._range_toggle = gtk.ToggleButton(_L('Range'))
        self._range_toggle.set_active(qt.config.get('Instrument View_show_range', True))
        self._range_toggle.connect('toggled', self._range_toggled_cb)
        self._rate_toggle = gtk.ToggleButton(_L('Rate'))
        self._rate_toggle.set_active(qt.config.get('Instrument View_show_rate', True))
        self._rate_toggle.connect('toggled', self._rate_toggled_cb)

        self._outer_vbox.pack_start(gui.pack_hbox([
            self._range_toggle,
            self._rate_toggle], True, True), False, False)

        self._ins_widgets = {}
        self._add_instruments()

        self._scrolled_win = gtk.ScrolledWindow()
        self._scrolled_win.set_policy(gtk.POLICY_AUTOMATIC, \
            gtk.POLICY_AUTOMATIC)
        self._scrolled_win.add_with_viewport(self._vbox)

        self._outer_vbox.pack_start(self._scrolled_win, True, True)

        self._outer_vbox.show_all()
        self._range_toggle.emit('toggled')
        self._rate_toggle.emit('toggled')
        self.add(self._outer_vbox)
Exemplo n.º 11
0
    def __init__(self, **kwargs):
        gtk.VBox.__init__(self, **kwargs)

        self._frontpanels = qt.frontpanels
        self._sliders = qt.sliders

        self._ins = None
        self._ins_combo = dropdowns.InstrumentDropdown()
        self._ins_combo.connect('changed', self._instrument_changed_cb)

        self._param_combo = dropdowns.InstrumentParameterDropdown()
        self._param_combo.connect('changed', self._parameter_changed_cb)

        self._get_but = gtk.Button('Get')
        self._get_but.connect('clicked', self._get_param_clicked_cb)
        self._param_edit = gtk.Entry()
        self._param_edit.set_alignment(0.93)
        self._set_but = gtk.Button('Set')
        self._set_but.connect('clicked', self._set_param_clicked_cb)
        param_getset = gui.pack_hbox([self._get_but, \
                self._set_but])

        self._function_frame = FunctionFrame()

        self._make_fp = gtk.Button('Frontpanel')
        self._make_fp.connect('clicked', self._fp_clicked_cb)

        self._make_sl = gtk.Button('Slider')
        self._make_sl.connect('clicked', self._slider_clicked_cb)

        h1 = gui.pack_hbox([gtk.Label(_L('Instrument')), self._ins_combo])
        h2 = gui.pack_hbox([gtk.Label(_L('Parameter')), self._param_combo])

        self._table = gtk.Table(4, 2, True)
        self._table.set_homogeneous(False)

        self._table.attach(h1, 0, 1, 0, 1)
        self._table.attach(h2, 0, 1, 1, 2)
        self._table.attach(self._param_edit, 0, 1, 2, 3)
        self._table.attach(self._function_frame, 0, 2, 3, 4)

        self._table.attach(self._make_fp, 1, 2, 0, 1)
        self._table.attach(self._make_sl, 1, 2, 1, 2)
        self._table.attach(param_getset, 1, 2, 2, 3)

        self._table.set_border_width(4)
        self.add(self._table)

        self._parameter_changed_cb(None)
        self.show_all()
Exemplo n.º 12
0
    def __init__(self):
        qtwindow.QTWindow.__init__(self, 'control', 'Instrument Control')
        self.connect("delete-event", self._delete_event_cb)

        self._set_frame = QTSetInstrumentFrame()
        self._manage_frame = QTManageInstrumentFrame()
        self._create_frame = QTCreateInstrumentFrame()

        self._notebook = gtk.Notebook()
        self._notebook.append_page(self._set_frame, gtk.Label(_L('Set')))
        self._notebook.append_page(self._manage_frame, gtk.Label(_L('Manage')))
        self._notebook.append_page(self._create_frame, gtk.Label(_L('Create')))
        self._notebook.show_all()
        self._notebook.set_current_page(0)
        self.add(self._notebook)
Exemplo n.º 13
0
    def __init__(self, name, title, add_to_main=True):
        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)

        self._name = self.generate_name(name)
        self._title = title

        winx, winy = config.get('%s_pos' % title, (250, 40))
        self.move(winx, winy)

        width, height = config.get('%s_size' % self._title, (200, 400))
        self.set_size_request(50, 50)
        self.resize(width, height)

        self.set_border_width(1)

        self.set_title(_L(title))

        show = config.get('%s_show' % self._title, False)
        if show:
            gobject.timeout_add(100, self._do_show)

        self.connect('configure-event', self._configure_event_cb)
        self.connect('show', lambda x: self._show_hide_cb(x, True))
        self.connect('hide', lambda x: self._show_hide_cb(x, False))

        QTWindow._window_list.add(self._name, self)

        if add_to_main:
            self._add_to_main()
Exemplo n.º 14
0
    def __init__(self, ins):
        if type(ins) is types.StringType:
            ins = qt.instruments[ins]

        self._instrument = ins
        if ins is not None:
            name = ins.get_name()
        else:
            name = "Instrument undefined"

        title = _L("Instrument: %s") % name
        qtwindow.QTWindow.__init__(self, name, title, add_to_main=False)
        self.connect("delete-event", self._delete_event_cb)

        self._param_info = {}

        self._table = gtk.Table(1, 3)
        self._add_parameters()
        self._add_functions()

        self._get_all_but = gtk.Button("Get all")
        self._get_all_but.connect("clicked", self._get_all_clicked_cb)

        self._vbox = gtk.VBox()
        self._vbox.pack_start(self._table)
        self._vbox.pack_start(self._get_all_but, False, False)
        self.add(self._vbox)

        self.show_all()
Exemplo n.º 15
0
    def _measurement_finished_cb(self, sender):
        logging.debug('Measurement finished')
        self.set_sensitive(True)

        runtime = time.time() - self._measurement_start
        self._status_label.set_text(_L('Finished in %s') % \
            misc.seconds_to_str(runtime))
Exemplo n.º 16
0
    def _measurement_finished_cb(self, sender):
        logging.debug('Measurement finished')
        self.set_sensitive(True)

        runtime = time.time() - self._measurement_start
        self._status_label.set_text(_L('Finished in %s') % \
            misc.seconds_to_str(runtime))
Exemplo n.º 17
0
    def __init__(self, ins):
        if type(ins) is types.StringType:
            ins = qt.instruments[ins]

        self._instrument = ins
        if ins is not None:
            name = ins.get_name()
        else:
            name = 'Instrument undefined'

        title = _L('Instrument: %s') % name
        qtwindow.QTWindow.__init__(self, name, title, add_to_main=False)
        self.connect('delete-event', self._delete_event_cb)

        self._param_info = {}

        self._table = gtk.Table(1, 3)
        self._add_parameters()
        self._add_functions()

        self._get_all_but = gtk.Button('Get all')
        self._get_all_but.connect('clicked', self._get_all_clicked_cb)

        self._vbox = gtk.VBox()
        self._vbox.pack_start(self._table)
        self._vbox.pack_start(self._get_all_but, False, False)
        self.add(self._vbox)

        self.show_all()
Exemplo n.º 18
0
    def __init__(self, name, title, add_to_main=True):
        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)

        self._name = self.generate_name(name)
        self._title = title

        winx, winy = config.get('%s_pos' % title, (250, 40))
        self.move(winx, winy)

        width, height = config.get('%s_size' % self._title, (200, 400))
        self.set_size_request(50, 50)
        self.resize(width, height)

        self.set_border_width(1)

        self.set_title(_L(title))

        show = config.get('%s_show' % self._title, False)
        if show:
            gobject.timeout_add(100, self._do_show)

        self.connect('configure-event', self._configure_event_cb)
        self.connect('show', lambda x: self._show_hide_cb(x, True))
        self.connect('hide', lambda x: self._show_hide_cb(x, False))

        QTWindow._window_list.add(self._name, self)

        if add_to_main:
            self._add_to_main()
Exemplo n.º 19
0
    def check_abort(self):
        '''Check whether an abort has been requested.'''

        if self._abort:
            self._abort = False
            #self.emit('stop-request') # YS: try to get rid of 32bit gobject from pygtk
            self.measurement_end(abort=True)
            raise ValueError(_L('Human abort'))
Exemplo n.º 20
0
    def create_layout(self):
        self._frame = gtk.Frame()
        if self._label is not None:
            self._frame.set_label(self._label)

        self._vbox = gtk.VBox(spacing=4)
        self._vbox.set_border_width(4)

        self._variable_dropdown = AllParametersDropdown(
            flags=qt.constants.FLAG_SET,
            types=(types.IntType, types.FloatType),
            tags=['sweep'])
        self._variable_dropdown.connect('changed', self._parameter_changed_cb)
        self._vbox.pack_start(
            gui.pack_hbox(
                [gtk.Label(_L('Sweep variable')), self._variable_dropdown]),
            False, False)

        self._start_val = gtk.SpinButton(climb_rate=0.1, digits=2)
        self._start_val.set_range(0, 0)
        self._start_val.set_increments(0.01, 0.1)

        self._end_val = gtk.SpinButton(climb_rate=0.1, digits=2)
        self._end_val.set_range(0, 0)
        self._end_val.set_increments(0.01, 0.1)

        self._n_steps = gtk.SpinButton(climb_rate=0.1, digits=0)
        self._n_steps.set_range(0, 100000)
        self._n_steps.set_increments(1, 2)

        self._steps_or_size = StepToggleButton(
            [_L('< Steps'), _L('Size >')], self._steps_toggle_cb,
            _L('Set number of steps or stepsize'))
        self._steps_or_size.set_size_request(100, 0)

        self._step_size = gtk.SpinButton(climb_rate=0.1, digits=3)
        self._step_size.set_range(0, 1000)
        self._step_size.set_increments(0.001, 0.01)
        self._step_size.set_sensitive(False)

        self._units_label = gtk.Label()

        self._vbox.pack_start(
            gui.pack_hbox([
                gtk.Label(_L('Start')), self._start_val,
                gtk.Label(_L('End')), self._end_val, self._units_label
            ]))

        self._vbox.pack_start(
            gui.pack_hbox([
                gtk.Label(_L('Nr of steps')), self._n_steps,
                self._steps_or_size,
                gtk.Label(_L('Step size')), self._step_size
            ]))

        self._frame.add(self._vbox)
Exemplo n.º 21
0
    def check_abort(self):
        '''Check whether an abort has been requested.'''

        if self._abort:
            self._abort = False
            self.emit('stop-request')
            self.measurement_end(abort=True)
            raise ValueError(_L('Human abort'))
Exemplo n.º 22
0
    def __init__(self):
        gtk.Button.__init__(self, _L('Stop'))

        self.set_sensitive(qt.flow.is_measuring())
        self.connect('clicked', self._toggle_stop_cb)

        qt.flow.connect('measurement-start', self._measurement_start_cb)
        qt.flow.connect('measurement-end', self._measurement_end_cb)
Exemplo n.º 23
0
    def __init__(self, **kwargs):
        gtk.VBox.__init__(self, **kwargs)

        self._instruments = qt.instruments

        self._add_frame = gtk.Frame()
        self._add_frame.set_label(_L('Create'))

        name_label = gtk.Label(_L('Name'))
        self._name_entry = gtk.Entry()
        self._name_entry.connect('changed', self._name_changed_cb)

        type_label = gtk.Label(_L('Type'))
        self._type_dropdown = dropdowns.InstrumentTypeDropdown()
        self._type_dropdown.connect('changed', self._dropdown_changed_cb)
        self._add_button = gtk.Button(_L('Add'))
        self._add_button.connect('clicked', self._add_clicked_cb)
        self._add_button.set_sensitive(False)

        gpib_label = gtk.Label(_L('GPIB')) #not necessary to have _L
        self._gpib_entry = gtk.Entry()        

        self._argument_table = ArgumentTable(3, 2, exclude=['self', 'name'])
        self._argument_table.attach(name_label, 0, 1, 0, 1)
        self._argument_table.attach(self._name_entry, 1, 2, 0, 1)
        self._argument_table.attach(type_label, 0, 1, 1, 2)
        self._argument_table.attach(self._type_dropdown, 1, 2, 1, 2)

        self._argument_table.attach(gpib_label, 0, 1, 2, 3)
        self._argument_table.attach(self._gpib_entry, 1, 2, 2, 3)


        vbox = gui.pack_vbox([
            self._argument_table,
            self._add_button
            ], False, False)
        vbox.set_border_width(4)
        self._add_frame.add(vbox)

        vbox = gui.pack_vbox([
            self._add_frame,
            ], False,False)
        vbox.set_border_width(4)
        self.add(vbox)

        self.show_all()
Exemplo n.º 24
0
    def check_abort(self):
        '''Check whether an abort has been requested.'''

        if self._abort:
            self._abort = False
            #self.emit('stop-request') # YS: try to get rid of 32bit gobject from pygtk
            self.measurement_end(abort=True)
            raise ValueError(_L('Human abort'))
Exemplo n.º 25
0
    def check_abort(self):
        '''Check whether an abort has been requested.'''

        if self._abort:
            self._abort = False
            self.emit('stop-request')
            self.measurement_end(abort=True)
            raise ValueError(_L('Human abort'))
Exemplo n.º 26
0
    def check_abort(self):
        """Check whether an abort has been requested."""

        if self._abort:
            self._abort = False
            self.emit("stop-request")
            self.measurement_end(abort=True)
            raise ValueError(_L("Human abort"))
Exemplo n.º 27
0
    def __init__(self):
        gtk.Button.__init__(self, _L('Stop'))

        self.set_sensitive(qt.flow.is_measuring())
        self.connect('clicked', self._toggle_stop_cb)

        qt.flow.connect('measurement-start', self._measurement_start_cb)
        qt.flow.connect('measurement-end', self._measurement_end_cb)
Exemplo n.º 28
0
    def create_layout(self):
        self._frame = gtk.Frame()
        if self._label is not None:
            self._frame.set_label(self._label)

        self._vbox = gtk.VBox(spacing=4)
        self._vbox.set_border_width(4)

        self._variable_dropdown = AllParametersDropdown(
                                    flags=qt.constants.FLAG_SET,
                                    types=(types.IntType, types.FloatType),
                                    tags=['sweep'])
        self._variable_dropdown.connect('changed', self._parameter_changed_cb)
        self._vbox.pack_start(gui.pack_hbox([
            gtk.Label(_L('Sweep variable')),
            self._variable_dropdown]), False, False)

        self._start_val = gtk.SpinButton(climb_rate=0.1, digits=2)
        self._start_val.set_range(0, 0)
        self._start_val.set_increments(0.01, 0.1)

        self._end_val = gtk.SpinButton(climb_rate=0.1, digits=2)
        self._end_val.set_range(0, 0)
        self._end_val.set_increments(0.01, 0.1)

        self._n_steps = gtk.SpinButton(climb_rate=0.1, digits=0)
        self._n_steps.set_range(0, 100000)
        self._n_steps.set_increments(1, 2)

        self._steps_or_size = StepToggleButton([_L('< Steps'), _L('Size >')],
            self._steps_toggle_cb, _L('Set number of steps or stepsize'))
        self._steps_or_size.set_size_request(100, 0)

        self._step_size = gtk.SpinButton(climb_rate=0.1, digits=3)
        self._step_size.set_range(0, 1000)
        self._step_size.set_increments(0.001, 0.01)
        self._step_size.set_sensitive(False)

        self._units_label = gtk.Label()

        self._vbox.pack_start(gui.pack_hbox([
            gtk.Label(_L('Start')),
            self._start_val,
            gtk.Label(_L('End')),
            self._end_val,
            self._units_label]))

        self._vbox.pack_start(gui.pack_hbox([
            gtk.Label(_L('Nr of steps')),
            self._n_steps,
            self._steps_or_size,
            gtk.Label(_L('Step size')),
            self._step_size]))

        self._frame.add(self._vbox)
Exemplo n.º 29
0
    def _measurement_finished_cb(self, sender, msg):
        logging.debug('Measurement finished: %s', msg)
        self.set_sensitive(True)
        if self._plot is not None:
            self._plot.save_png()

        runtime = time.time() - self._measurement_start
        self._status_label.set_text(_L('Finished in %s') % \
            misc.seconds_to_str(runtime))
Exemplo n.º 30
0
    def _measurement_finished_cb(self, sender, msg):
        logging.debug('Measurement finished: %s', msg)
        self.set_sensitive(True)
        if self._plot is not None:
            self._plot.save_png()

        runtime = time.time() - self._measurement_start
        self._status_label.set_text(_L('Finished in %s') % \
            misc.seconds_to_str(runtime))
Exemplo n.º 31
0
    def __init__(self):
        qtwindow.QTWindow.__init__(self, 'control', 'Instrument Control')
        self.connect("delete-event", self._delete_event_cb)

        self._set_frame = QTSetInstrumentFrame()
        self._manage_frame = QTManageInstrumentFrame()
        self._create_frame = QTCreateInstrumentFrame()

        self._notebook = gtk.Notebook()
        self._notebook.append_page(self._set_frame,
            gtk.Label(_L('Set')))
        self._notebook.append_page(self._manage_frame,
            gtk.Label(_L('Manage')))
        self._notebook.append_page(self._create_frame,
            gtk.Label(_L('Create')))
        self._notebook.show_all()
        self._notebook.set_current_page(0)
        self.add(self._notebook)
Exemplo n.º 32
0
    def __init__(self, **kwargs):
        gtk.VBox.__init__(self, **kwargs)

        self._instruments = qt.instruments

        self._add_frame = gtk.Frame()
        self._add_frame.set_label(_L('Create'))

        name_label = gtk.Label(_L('Name'))
        self._name_entry = gtk.Entry()
        self._name_entry.connect('changed', self._name_changed_cb)

        type_label = gtk.Label(_L('Type'))
        self._type_dropdown = dropdowns.InstrumentTypeDropdown()
        self._type_dropdown.connect('changed', self._dropdown_changed_cb)
        self._add_button = gtk.Button(_L('Add'))
        self._add_button.connect('clicked', self._add_clicked_cb)
        self._add_button.set_sensitive(False)

        gpib_label = gtk.Label(_L('GPIB'))  #not necessary to have _L
        self._gpib_entry = gtk.Entry()

        self._argument_table = ArgumentTable(3, 2, exclude=['self', 'name'])
        self._argument_table.attach(name_label, 0, 1, 0, 1)
        self._argument_table.attach(self._name_entry, 1, 2, 0, 1)
        self._argument_table.attach(type_label, 0, 1, 1, 2)
        self._argument_table.attach(self._type_dropdown, 1, 2, 1, 2)

        self._argument_table.attach(gpib_label, 0, 1, 2, 3)
        self._argument_table.attach(self._gpib_entry, 1, 2, 2, 3)

        vbox = gui.pack_vbox([self._argument_table, self._add_button], False,
                             False)
        vbox.set_border_width(4)
        self._add_frame.add(vbox)

        vbox = gui.pack_vbox([
            self._add_frame,
        ], False, False)
        vbox.set_border_width(4)
        self.add(vbox)

        self.show_all()
Exemplo n.º 33
0
    def set(self, name, value=None, fast=False, **kwargs):
        '''
        Set one or more Instrument parameter values.

        Checks whether the Instrument is locked and checks value bounds,
        if specified by minval / maxval.

        Input:
            name (string or dict): which parameter to set, or dictionary of
                parameter -> value
            value (any): the value to set
            fast (bool): if True perform as fast as possible, e.g. don't
                emit a signal to update the GUI.
            kwargs: Optional keyword args that will be passed on.

        Output: True or False whether the operation succeeded.
                For multiple sets return False if any of the parameters failed.
        '''

        if self._locked:
            logging.warning('Trying to set value of locked instrument (%s)',
                    self.get_name())
            return False

        if Instrument.USE_ACCESS_LOCK:
            if not self._access_lock.acquire():
                logging.warning(_L('Failed to acquire lock!'))
                return None

        result = True
        changed = {}
        if type(name) == types.DictType:
            for key, val in name.iteritems():
                val = self._set_value(key, val, **kwargs)
                if val is not None:
                    changed[key] = val
                else:
                    result = False

        else:
            val = self._set_value(name, value, **kwargs)
            if val is not None:
                changed[name] = val
            else:
                result = False

        if Instrument.USE_ACCESS_LOCK:
            self._access_lock.release()

        if not fast and len(changed) > 0:
            self._queue_changed(changed)
        #qt.msleep()
        msleep() # YS: instead of importing qt, import the required tools from qtflow directly
        return result
Exemplo n.º 34
0
    def _measurement_progress_cb(self, sender, vals):
        running = time.time() - self._measurement_start

        if vals['current'] > 0:
            predicted = running / vals['current'] * vals['total'] - running
        else:
            predicted = 0

        text = _L('Step %d / %d, running: %s, remaining: %s') % \
            (vals['current'], vals['total'], misc.seconds_to_str(running), \
            misc.seconds_to_str(predicted))
        self._status_label.set_text(text)
Exemplo n.º 35
0
    def _measurement_progress_cb(self, sender, vals):
        running = time.time() - self._measurement_start

        if vals['current'] > 0:
            predicted = running / vals['current'] * vals['total'] - running
        else:
            predicted = 0

        text = _L('Step %d / %d, running: %s, remaining: %s') % \
            (vals['current'], vals['total'], misc.seconds_to_str(running), \
            misc.seconds_to_str(predicted))
        self._status_label.set_text(text)
Exemplo n.º 36
0
    def __init__(self):
        if MainWindow._main_created:
            logging.error('Error: Main window already created!')
            return
        MainWindow._main_created = True

        qtwindow.QTWindow.__init__(self, 'main', 'QT Lab', add_to_main=False)
        self.connect("delete-event", self._delete_event_cb)
        self.connect("destroy", self._destroy_cb)

        self.vbox = gtk.VBox()

        menu = [
            {'name': _L('File'), 'icon': '', 'submenu':
                [
                {'name': _L('Save'), 'icon': '', 'action': self._save_cb},
                {'name': _L('Exit'), 'icon': '', 'action': self._exit_cb}
                ]
            },
            {'name': _L('Help'), 'icon': '', 'submenu':
                [
                {'name': _L('About'), 'icon': ''}
                ]
            }
        ]
#        self.menu = gui.build_menu(menu)

        self._liveplot_but = gtk.ToggleButton(_L('Live Plotting'))
        self._liveplot_but.set_active(qt.flow.get_live_plot())
        self._liveplot_but.connect('clicked', self._toggle_liveplot_cb)
        self._replot_but = gtk.Button(_L('Replot'))
        self._replot_but.connect('clicked', self._toggle_replot_cb)
        self._stop_but = stopbutton.StopButton()
        self._pause_but = stopbutton.PauseButton()

        self._AWG_but = gtk.Button(_L('AWG Interface'))
        self._AWG_but.connect('clicked',self._AWG_but_handler)


        vbox = gui.orderedbox.OrderedVBox()
        vbox.add(self._liveplot_but, 10, False)
        vbox.add(self._replot_but, 11, False)
        vbox.add(self._stop_but, 12, False)
        vbox.add(self._pause_but, 13, True)
        vbox.add(self._AWG_but,20,False)
        self._vbox = vbox
        self.add(self._vbox)


        self.show_all()
Exemplo n.º 37
0
    def _dir_button_clicked_cb(self, sender):
        chooser = gtk.FileChooserDialog(
            title=_L('Select data file'),
            action=gtk.FILE_CHOOSER_ACTION_OPEN,
            buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN,
                     gtk.RESPONSE_OK))
        chooser.set_current_folder('Q:/')
        ret = chooser.run()
        if ret == gtk.RESPONSE_OK:
            self._dir_entry.set_text(chooser.get_filename())
            self._dir_entry.activate()

        chooser.destroy()
Exemplo n.º 38
0
    def __init__(self, **kwargs):
        gtk.VBox.__init__(self, **kwargs)

        self._instruments = qt.instruments
        self._frontpanels = qt.frontpanels

        self._action_frame = gtk.Frame()
        self._action_frame.set_label(_L('Manage'))

        self._ins_dropdown = dropdowns.InstrumentDropdown()

        self._frontpanel_button = gtk.Button(_L('Frontpanel'))
        self._frontpanel_button.connect('clicked', self._fp_clicked_cb)

        self._reload_button = gtk.Button(_L('Reload'))
        self._reload_button.connect('clicked', self._reload_clicked_cb)

        self._remove_button = gtk.Button(_L('Remove'))
        self._remove_button.connect('clicked', self._remove_clicked_cb)

        vbox = gui.pack_vbox([
            self._ins_dropdown,
            gui.pack_hbox([
                self._frontpanel_button,
                self._reload_button,
                self._remove_button
                ], True, True)
            ], False, False)
        vbox.set_border_width(4)
        self._action_frame.add(vbox)

        vbox = gui.pack_vbox([
            self._action_frame
            ], False,False)
        vbox.set_border_width(4)

        self.add(vbox)

        self.show_all()
Exemplo n.º 39
0
    def _dir_button_clicked_cb(self, sender):
        chooser = gtk.FileChooserDialog(
                title=_L('Select directory'),
                action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
                buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                    gtk.STOCK_OPEN, gtk.RESPONSE_OK))

        ret = chooser.run()
        if ret == gtk.RESPONSE_OK:
            self._dir_entry.set_text(chooser.get_filename())
            self._dir_entry.activate()

        chooser.destroy()
Exemplo n.º 40
0
    def __init__(self, axis):
        gtk.Frame.__init__(self, 'Axis %s' % axis)
        self._axis = axis
        self._plot = None
        self._ignore_changes = False

        self._label_entry = gtk.Entry()
        self._label_but = gtk.Button(_L('Set'))
        self._label_but.connect('clicked', self._label_clicked_cb)
        self._label_entry.connect('activate', self._label_clicked_cb)

        self._min_range = gtk.Entry()
        self._min_range.set_width_chars(10)
        self._max_range = gtk.Entry()
        self._max_range.set_width_chars(10)
        self._range_but = gtk.Button(_L('Set'))
        self._range_but.connect('clicked', self._range_clicked_cb)
        self._min_range.connect('activate', self._range_clicked_cb)
        self._max_range.connect('activate', self._range_clicked_cb)

        self._logcheck = gtk.CheckButton('Log')
        self._logcheck.set_active(False)
        self._logcheck.connect('toggled', self._log_toggled_cb)

        vbox = gui.pack_vbox([
            gui.pack_hbox([
                gtk.Label(_L('Label')),
                self._label_entry,
                self._label_but], True, True),
            gui.pack_hbox([
                self._logcheck,
                gtk.Label(_L('Range')),
                self._min_range,
                self._max_range,
                self._range_but], True, True),
            ], False, False)

        self.add(vbox)
Exemplo n.º 41
0
    def __init__(self):
        if MainWindow._main_created:
            logging.error('Error: Main window already created!')
            return
        MainWindow._main_created = True

        qtwindow.QTWindow.__init__(self, 'main', 'QT Lab', add_to_main=False)
        self.connect("delete-event", self._delete_event_cb)
        self.connect("destroy", self._destroy_cb)

        self.vbox = gtk.VBox()

        menu = [{
            'name':
            _L('File'),
            'icon':
            '',
            'submenu': [{
                'name': _L('Save'),
                'icon': '',
                'action': self._save_cb
            }, {
                'name': _L('Exit'),
                'icon': '',
                'action': self._exit_cb
            }]
        }, {
            'name': _L('Help'),
            'icon': '',
            'submenu': [{
                'name': _L('About'),
                'icon': ''
            }]
        }]
        #        self.menu = gui.build_menu(menu)

        self._liveplot_but = gtk.ToggleButton(_L('Live Plotting'))
        self._liveplot_but.set_active(qt.flow.get_live_plot())
        self._liveplot_but.connect('clicked', self._toggle_liveplot_cb)
        self._replot_but = gtk.Button(_L('Replot'))
        self._replot_but.connect('clicked', self._toggle_replot_cb)
        self._stop_but = stopbutton.StopButton()
        self._pause_but = stopbutton.PauseButton()

        vbox = gui.orderedbox.OrderedVBox()
        vbox.add(self._liveplot_but, 10, False)
        vbox.add(self._replot_but, 11, False)
        vbox.add(self._stop_but, 12, False)
        vbox.add(self._pause_but, 13, True)
        self._vbox = vbox
        self.add(self._vbox)

        self.show_all()
Exemplo n.º 42
0
    def __init__(self, **kwargs):
        gtk.VBox.__init__(self, **kwargs)

        self._instruments = qt.instruments
        self._frontpanels = qt.frontpanels

        self._action_frame = gtk.Frame()
        self._action_frame.set_label(_L('Manage'))

        self._ins_dropdown = dropdowns.InstrumentDropdown()

        self._frontpanel_button = gtk.Button(_L('Frontpanel'))
        self._frontpanel_button.connect('clicked', self._fp_clicked_cb)

        self._reload_button = gtk.Button(_L('Reload'))
        self._reload_button.connect('clicked', self._reload_clicked_cb)

        self._remove_button = gtk.Button(_L('Remove'))
        self._remove_button.connect('clicked', self._remove_clicked_cb)

        vbox = gui.pack_vbox([
            self._ins_dropdown,
            gui.pack_hbox([
                self._frontpanel_button, self._reload_button,
                self._remove_button
            ], True, True)
        ], False, False)
        vbox.set_border_width(4)
        self._action_frame.add(vbox)

        vbox = gui.pack_vbox([self._action_frame], False, False)
        vbox.set_border_width(4)

        self.add(vbox)

        self.show_all()
    def _save_as_cb(self, sender):
        chooser = gtk.FileChooserDialog(
            _L('Save as'), None,
            action=gtk.FILE_CHOOSER_ACTION_SAVE,
            buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
            gtk.STOCK_SAVE, gtk.RESPONSE_OK))

        chooser.add_filter(get_python_filter())

        result = chooser.run()
        if result == gtk.RESPONSE_OK:
            filename = chooser.get_filename()
            self.save_file(filename)

        chooser.destroy()
    def _open_cb(self, sender):
        chooser = gtk.FileChooserDialog(
            _L('Select file'), None,
            action=gtk.FILE_CHOOSER_ACTION_OPEN,
            buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
            gtk.STOCK_OPEN, gtk.RESPONSE_OK))

        chooser.add_filter(get_python_filter())

        result = chooser.run()
        if result == gtk.RESPONSE_OK:
            filename = chooser.get_filename()
            self.load_file(filename)

        chooser.destroy()
    def _open_cb(self, sender):
        chooser = gtk.FileChooserDialog(
            _L('Select file'), None,
            action=gtk.FILE_CHOOSER_ACTION_OPEN,
            buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
            gtk.STOCK_OPEN, gtk.RESPONSE_OK))

        chooser.add_filter(get_python_filter())

        result = chooser.run()
        if result == gtk.RESPONSE_OK:
            filename = chooser.get_filename()
            self.load_file(filename)

        chooser.destroy()
    def _find_cb(self, sender):
        dialog = gtk.Dialog(title=_L('Find'), parent=self,
                            flags=gtk.DIALOG_MODAL,
                            buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                            gtk.STOCK_OK, gtk.RESPONSE_OK))
        vbox = dialog.vbox
        entry = gtk.Entry()
        vbox.pack_start(entry, False, False)
        vbox.show_all()
        res = dialog.run()
        if res == gtk.RESPONSE_OK:
            text = entry.get_text()
            self._do_find(text)

        dialog.destroy()
    def _save_as_cb(self, sender):
        chooser = gtk.FileChooserDialog(
            _L('Save as'), None,
            action=gtk.FILE_CHOOSER_ACTION_SAVE,
            buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
            gtk.STOCK_SAVE, gtk.RESPONSE_OK))

        chooser.add_filter(get_python_filter())

        result = chooser.run()
        if result == gtk.RESPONSE_OK:
            filename = chooser.get_filename()
            self.save_file(filename)

        chooser.destroy()
    def _find_cb(self, sender):
        dialog = gtk.Dialog(title=_L('Find'), parent=self,
                            flags=gtk.DIALOG_MODAL,
                            buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                            gtk.STOCK_OK, gtk.RESPONSE_OK))
        vbox = dialog.vbox
        entry = gtk.Entry()
        vbox.pack_start(entry, False, False)
        vbox.show_all()
        res = dialog.run()
        if res == gtk.RESPONSE_OK:
            text = entry.get_text()
            self._do_find(text)

        dialog.destroy()
Exemplo n.º 49
0
    def __init__(self, axis):
        gtk.Frame.__init__(self, 'Axis %s' % axis)
        self._axis = axis
        self._plot = None
        self._ignore_changes = False

        self._label_entry = gtk.Entry()
        self._label_but = gtk.Button(_L('Set'))
        self._label_but.connect('clicked', self._label_clicked_cb)
        self._label_entry.connect('activate', self._label_clicked_cb)

        self._min_range = gtk.Entry()
        self._min_range.set_width_chars(10)
        self._max_range = gtk.Entry()
        self._max_range.set_width_chars(10)
        self._range_but = gtk.Button(_L('Set'))
        self._range_but.connect('clicked', self._range_clicked_cb)
        self._min_range.connect('activate', self._range_clicked_cb)
        self._max_range.connect('activate', self._range_clicked_cb)

        self._logcheck = gtk.CheckButton('Log')
        self._logcheck.set_active(False)
        self._logcheck.connect('toggled', self._log_toggled_cb)

        vbox = gui.pack_vbox([
            gui.pack_hbox(
                [gtk.Label(_L('Label')), self._label_entry, self._label_but],
                True, True),
            gui.pack_hbox([
                self._logcheck,
                gtk.Label(_L('Range')), self._min_range, self._max_range,
                self._range_but
            ], True, True),
        ], False, False)

        self.add(vbox)
Exemplo n.º 50
0
    def get(self, name, query=True, fast=False, **kwargs):
        '''
        Get one or more Instrument parameter values.

        Input:
            name (string or list/tuple of strings): name of parameter(s)
            query (bool): whether to query the instrument or return the
                last stored value
            fast (bool): if True perform as fast as possible, e.g. don't
                emit a signal to update the GUI.
            kwargs: Optional keyword args that will be passed on.

        Output: Single value, or dictionary of parameter -> values
                Type is whatever the instrument driver returns.
        '''

        if Instrument.USE_ACCESS_LOCK:
            if not self._access_lock.acquire():
                logging.warning(_L('Failed to acquire lock!'))
                return None

        if fast:
            ret = self._get_value(name, query, **kwargs)
            if Instrument.USE_ACCESS_LOCK:
                self._access_lock.release()
            return ret

        if type(name) in (types.ListType, types.TupleType):
            changed = {}
            result = {}
            for key in name:
                val = self._get_value(key, query, **kwargs)
                if val is not None:
                    result[key] = val
                    changed[key] = val

        else:
            result = self._get_value(name, query, **kwargs)
            changed = {name: result}

        if Instrument.USE_ACCESS_LOCK:
            self._access_lock.release()

        if len(changed) > 0 and query:
            self._queue_changed(changed)
        #qt.msleep()
        msleep() # YS: instead of importing qt, import the required tools from qtflow directly
        return result
Exemplo n.º 51
0
    def __init__(self):
        QTWindow.__init__(self, 'positioner', 'Positioner')
        self.connect("delete-event", self._delete_event_cb)

        self._moving = False

        self._controls = PositionControls(None)
        self._controls.connect('direction-clicked', self._direction_clicked_cb)
        self._controls.connect('direction-released', self._direction_released_cb)
        self._controls.connect('max-speed-changed', self._max_speed_changed_cb)
        self._controls.connect('min-speed-changed', self._min_speed_changed_cb)
        self._controls.connect('accel-changed', self._accel_changed_cb)
        self._controls.connect('decel-changed', self._decel_changed_cb)
        self._controls.connect('stop-request', self._stop_request_cb)
        self._max_speed = self._controls.get_max_speed()
        self._min_speed = self._controls.get_min_speed()
        self._accel_factor = self._controls.get_accel()
        self._decel_factor = self._controls.get_decel()

        self._bookmarks = PositionBookmarks(None)
        self._bookmarks.connect('go-request', self._go_request)

        self._ins_combo = InstrumentDropdown(types=['positioner'])
        self._ins_combo.connect('changed', self._instrument_changed_cb)
        self._instrument = None

        poslabel = gtk.Label()
        poslabel.set_markup('<big>%s</big>' % _L('Position'))
        self._position_label = gtk.Label()
        self._update_position()

        vbox = pack_vbox([
            self._ins_combo,
            pack_hbox([
                poslabel,
                self._position_label], True, True),
            self._controls,
            self._bookmarks], False, False)

        # Speed control variables
        self._direction_down = (0, 0, 0)
        self._step_done = False
        self._speed = [0, 0, 0]
        self._timer_hid = None
        self._counter = 0

        self.add(vbox)
        vbox.show_all()
Exemplo n.º 52
0
    def __init__(self):
        QTWindow.__init__(self, 'positioner', 'Positioner')
        self.connect("delete-event", self._delete_event_cb)

        self._moving = False

        self._controls = PositionControls(None)
        self._controls.connect('direction-clicked', self._direction_clicked_cb)
        self._controls.connect('direction-released', self._direction_released_cb)
        self._controls.connect('max-speed-changed', self._max_speed_changed_cb)
        self._controls.connect('min-speed-changed', self._min_speed_changed_cb)
        self._controls.connect('accel-changed', self._accel_changed_cb)
        self._controls.connect('decel-changed', self._decel_changed_cb)
        self._controls.connect('stop-request', self._stop_request_cb)
        self._max_speed = self._controls.get_max_speed()
        self._min_speed = self._controls.get_min_speed()
        self._accel_factor = self._controls.get_accel()
        self._decel_factor = self._controls.get_decel()

        self._bookmarks = PositionBookmarks(None)
        self._bookmarks.connect('go-request', self._go_request)

        self._ins_combo = InstrumentDropdown(types=['positioner'])
        self._ins_combo.connect('changed', self._instrument_changed_cb)
        self._instrument = None

        poslabel = gtk.Label()
        poslabel.set_markup('<big>%s</big>' % _L('Position'))
        self._position_label = gtk.Label()
        self._update_position()

        vbox = pack_vbox([
            self._ins_combo,
            pack_hbox([
                poslabel,
                self._position_label], True, True),
            self._controls,
            self._bookmarks], False, False)

        # Speed control variables
        self._direction_down = (0, 0, 0)
        self._step_done = False
        self._speed = [0, 0, 0]
        self._timer_hid = None
        self._counter = 0

        self.add(vbox)
        vbox.show_all()
Exemplo n.º 53
0
    def __init__(self, ins, show_range, show_rate, **kwargs):
        gtk.VBox.__init__(self, **kwargs)

        self._label = gtk.Label()
        self._label.set_tooltip_text(_L('Click to expand / collapse info'))
        self._label.set_alignment(0, 0)
        self._eventbox = gtk.EventBox()
        self._eventbox.add(self._label)
        self._eventbox.connect('button-press-event', self._label_clicked_cb)
        self._eventbox.show_all()
        self.pack_start(self._eventbox, False, False)

        self._table = gtk.Table(1, 5)
        self._table.set_col_spacings(10)
        self._table.set_col_spacing(0, 50)
        self._table.show()
        self.pack_start(self._table, False, False)

        self._instrument = ins
        self._instrument_name = ins.get_name()
        self._label_name = {}
        self._label_val = {}
        self._label_range = {}
        self._label_rate = {}
        self._update_dict = {}
        self._cur_val = {}
        self._row_num = {}
        self._reorder_hid = None

        # For formatting
        self._parameter_options = {}

        self._add_parameters()

        ins.connect('parameter-added', self._parameter_added_cb)
        ins.connect('parameter-changed', self._parameter_changed_cb)
        ins.connect('parameter-removed', self._parameter_removed_cb)

        self.show_table(True)
        self.show()
        self.show_range_column(show_range)
        self.show_rate_column(show_rate)

        # Update variables twice per second
        gobject.timeout_add(500, self._do_update_parameters_timer)
    def __init__(self, ins, show_range, show_rate, **kwargs):
        gtk.VBox.__init__(self, **kwargs)

        self._label = gtk.Label()
        self._label.set_tooltip_text(_L('Click to expand / collapse info'))
        self._label.set_alignment(0, 0)
        self._eventbox = gtk.EventBox()
        self._eventbox.add(self._label)
        self._eventbox.connect('button-press-event', self._label_clicked_cb)
        self._eventbox.show_all()
        self.pack_start(self._eventbox, False, False)

        self._table = gtk.Table(1, 5)
        self._table.set_col_spacings(10)
        self._table.set_col_spacing(0, 50)
        self._table.show()
        self.pack_start(self._table, False, False)

        self._instrument = ins
        self._instrument_name = ins.get_name()
        self._label_name = {}
        self._label_val = {}
        self._label_range = {}
        self._label_rate = {}
        self._update_dict = {}
        self._cur_val = {}
        self._row_num = {}
        self._reorder_hid = None

        # For formatting
        self._parameter_options = {}

        self._add_parameters()

        ins.connect('parameter-added', self._parameter_added_cb)
        ins.connect('parameter-changed', self._parameter_changed_cb)
        ins.connect('parameter-removed', self._parameter_removed_cb)

        self.show_table(True)
        self.show()
        self.show_range_column(show_range)
        self.show_rate_column(show_rate)

        # Update variables twice per second
        gobject.timeout_add(500, self._do_update_parameters_timer)
Exemplo n.º 55
0
    def __init__(self):
        if MainWindow._main_created:
            logging.error("Error: Main window already created!")
            return
        MainWindow._main_created = True

        qtwindow.QTWindow.__init__(self, "main", "QT Lab", add_to_main=False)
        self.connect("delete-event", self._delete_event_cb)
        self.connect("destroy", self._destroy_cb)

        self.vbox = gtk.VBox()

        menu = [
            {
                "name": _L("File"),
                "icon": "",
                "submenu": [
                    {"name": _L("Save"), "icon": "", "action": self._save_cb},
                    {"name": _L("Exit"), "icon": "", "action": self._exit_cb},
                ],
            },
            {"name": _L("Help"), "icon": "", "submenu": [{"name": _L("About"), "icon": ""}]},
        ]
        #        self.menu = gui.build_menu(menu)

        self._liveplot_but = gtk.ToggleButton(_L("Live Plotting"))
        self._liveplot_but.set_active(qt.flow.get_live_plot())
        self._liveplot_but.connect("clicked", self._toggle_liveplot_cb)
        self._replot_but = gtk.Button(_L("Replot"))
        self._replot_but.connect("clicked", self._toggle_replot_cb)
        self._stop_but = stopbutton.StopButton()
        self._pause_but = stopbutton.PauseButton()

        vbox = gui.orderedbox.OrderedVBox()
        vbox.add(self._liveplot_but, 10, False)
        vbox.add(self._replot_but, 11, False)
        vbox.add(self._stop_but, 12, False)
        vbox.add(self._pause_but, 13, True)
        self._vbox = vbox
        self.add(self._vbox)

        self.show_all()
Exemplo n.º 56
0
    def __init__(self, ins):
        gtk.Frame.__init__(self)

        self.set_label(_L('Bookmarks'))

        self._add_button = gtk.Button(_L('Add'))
        self._add_button.connect('clicked', self._add_clicked_cb)

        self._goxy_button = gtk.Button(_L('Goto XY'))
        self._goxy_button.connect('clicked', self._go_clicked_cb, 2)

        self._goxyz_button = gtk.Button(_L('Goto XYZ'))
        self._goxyz_button.connect('clicked', self._go_clicked_cb, 3)

        self._remove_button = gtk.Button(_L('Remove'))
        self._remove_button.connect('clicked', self._remove_clicked_cb)

        self._bookmark_data = {}
        self._tree_model = gtk.ListStore(str, str)
        self._tree_view = QTTable([
            ('Label', {}),
            ('Position', {})
            ], self._tree_model)

        self._config = qt.config
        self._load_bookmarks()

        self._label_entry = gtk.Entry()

        self.set_instrument(ins)

        vbox = pack_vbox([
                pack_hbox([
                    gtk.Label(_L('Label')),
                    self._label_entry], True, False),
                pack_hbox([
                    self._add_button,
                    self._goxy_button,
                    self._goxyz_button,
                    self._remove_button], True, True),
                self._tree_view
                ], False, False)
        vbox.set_border_width(4)

        self.add(vbox)
Exemplo n.º 57
0
    def __init__(self):
        '''
        Initialization of main window
        '''
        self._plottype = 'none'

        # Create a new window
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)

        # Set title
        self.window.set_title("QTLab Analysis")

        # Handler for delete_event
        self.window.connect("delete_event", self.delete_event)

        # Border for the window
        self.window.set_border_width(10)

        # Buttons
        self.plot2d_button = gtk.Button("Plot XY")
        self.plot2d_button.connect("clicked", self.plot2d_cb)

        self.plot3d_button = gtk.Button("Plot XYZ")
        self.plot3d_button.connect("clicked", self.plot3d_cb)

        # Dropdowns
        self._data_dropdown = dropdowns.NamedListDropdown(qt.data)
        self._data_dropdown.connect('changed', self._data_dropdown_changed_cb)

        self._colnames_dropdown_x = dropdowns.StringListDropdown([])
        self._colnames_dropdown_y = dropdowns.StringListDropdown([])
        self._colnames_dropdown_z = dropdowns.StringListDropdown([])

        # Checkboxes
        self._hold_check = gtk.CheckButton('Hold on')
        self._hold_check.set_active(False)

        self._newfig_check = gtk.CheckButton('New figure')
        self._newfig_check.set_active(False)
        self._nfig = 1

        self._liveplot_check = gtk.CheckButton('Live plot')
        self._liveplot_check.set_active(False)
        self._liveplot_check.connect("clicked", self._liveplot_cb)
        self._hid = 0  # Proxy connect hid

        # Pack vbox
        self.vbox = gui.pack_vbox([
            gui.pack_hbox(
                [gtk.Label(_L('Choose data: ')), self._data_dropdown], True,
                True),
            gui.pack_hbox([gtk.Label(_L('X: ')), self._colnames_dropdown_x],
                          True, True),
            gui.pack_hbox([gtk.Label(_L('Y: ')), self._colnames_dropdown_y],
                          True, True),
            gui.pack_hbox([gtk.Label(_L('Z: ')), self._colnames_dropdown_z],
                          True, True),
            self.plot2d_button,
            self.plot3d_button,
            gui.pack_hbox(
                [self._hold_check, self._newfig_check, self._liveplot_check],
                True, True),
        ], False, False)
        self.window.add(self.vbox)

        self._data_dropdown.show()
        self._colnames_dropdown_x.show()
        self._colnames_dropdown_y.show()
        self._colnames_dropdown_z.show()
        self.plot2d_button.show()
        self.plot3d_button.show()
        self.vbox.show_all()
        self.window.show()
Exemplo n.º 58
0
    def __init__(self):
        '''
        Initialization of main window
        '''
        # Default parameters
        self._nfig = 1
        self._hid = 0  # Proxy connect hid
        self._plottype = 'none'
        self._data_obj = None
        self._operations = [
            'None', 'Plot 2D', 'Plot 3D', 'Plot 2D Difference',
            'Plot 3D - horizontal offset', 'Plot 3D - vertical offset',
            'Plot 3D - horizontal difference', 'Plot 3D - vertical difference',
            'Close all'
        ]
        self._cid = 0  # Connect ID for crosshair
        self._xdata = None
        self._ydata = None
        self._x = None
        self._y = None
        self._z = None
        self._offset = None

        # Create a new window
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)

        # Set title
        self.window.set_title("QTLab Analysis")

        # Handler for delete_event
        self.window.connect("delete_event", self._delete_event)

        # Border for the window
        self.window.set_border_width(10)

        # Button
        # self.plot2d_button = gtk.Button("Plot XY")
        # self.plot2d_button.connect("clicked", self._plot2d_cb)

        # self.plot3d_button = gtk.Button("Plot XYZ")
        # self.plot3d_button.connect("clicked", self._plot3d_cb)

        self.go_button = gtk.Button("Go")
        self.go_button.connect("clicked", self._go_cb)

        self._dir_entry = gtk.Entry()
        self._dir_entry.connect('activate', self._dir_activate_cb)

        self._dir_button = gtk.Button(_L('Browse'))
        self._dir_button.connect('clicked', self._dir_button_clicked_cb)

        self._dir_hbox = gui.pack_hbox((gtk.Label('Choose filename (*.dat): '),
                                        self._dir_entry, self._dir_button),
                                       True, True)

        # Dropdowns
        self._data_dropdown = dropdowns.NamedListDropdown(qt.data)
        self._data_dropdown.connect('changed', self._data_dropdown_changed_cb)

        self._colnames_dropdown_x = dropdowns.StringListDropdown([])
        self._colnames_dropdown_y = dropdowns.StringListDropdown([])
        self._colnames_dropdown_z = dropdowns.StringListDropdown([])
        self._operations_dropdown = dropdowns.StringListDropdown(
            self._operations)
        self._operations_dropdown.connect('changed',
                                          self._operations_dropdown_changed_cb)

        # Checkboxes
        self._hold_check = gtk.CheckButton('Hold on')
        self._hold_check.set_active(False)

        self._newfig_check = gtk.CheckButton('New figure')
        self._newfig_check.set_active(False)

        self._liveplot_check = gtk.CheckButton('Live plot')
        self._liveplot_check.set_active(False)
        self._liveplot_check.connect("clicked", self._liveplot_cb)

        # Pack vbox
        self.vbox = gui.pack_vbox([
            gui.pack_hbox(
                [gtk.Label(_L('Choose data: ')), self._data_dropdown], True,
                True),
            self._dir_hbox,
            gui.pack_hbox([gtk.Label(_L('X: ')), self._colnames_dropdown_x],
                          True, True),
            gui.pack_hbox([gtk.Label(_L('Y: ')), self._colnames_dropdown_y],
                          True, True),
            gui.pack_hbox([gtk.Label(_L('Z: ')), self._colnames_dropdown_z],
                          True, True),
            gui.pack_hbox(
                [gtk.Label(_L('Operations: ')), self._operations_dropdown],
                True, True),
            self.go_button,
            gui.pack_hbox(
                [self._hold_check, self._newfig_check, self._liveplot_check],
                True, True),
        ], False, False)
        self.window.add(self.vbox)

        self._data_dropdown.show()
        self._colnames_dropdown_x.show()
        self._colnames_dropdown_y.show()
        self._colnames_dropdown_z.show()
        self._operations_dropdown.show()
        self.go_button.show()
        self.vbox.show_all()
        self.window.show()