Beispiel #1
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()
Beispiel #2
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()
class QTCreateInstrumentFrame(gtk.VBox):

    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)

        self._argument_table = ArgumentTable(2, 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)

        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()

    def _dropdown_changed_cb(self, widget):
        type_name = self._type_dropdown.get_typename()
        if type_name is None:
            args = None
        else:
            args = self._instruments.get_type_arguments(type_name)
        self._argument_table.set_arg_spec(args)

        self._update_add_button_sensitivity()

    def _add_clicked_cb(self, widget):
        name = self._name_entry.get_text()
        typename = self._type_dropdown.get_typename()
        args = self._argument_table.get_args()
        logging.debug("Creating %s as %s, **args: %r", name, typename, args)
        ins = qt.instruments.create(name, typename, **args)
        if ins is not None:
            self._name_entry.set_text('')
            self._type_dropdown.select_none_type()

    def _name_changed_cb(self, widget):
        self._update_add_button_sensitivity()

    def _update_add_button_sensitivity(self):
        typename = self._type_dropdown.get_typename()
        namelen = len(self._name_entry.get_text())

        if typename is not None and typename != '' and namelen > 0:
            self._add_button.set_sensitive(True)
        else:
            self._add_button.set_sensitive(False)
Beispiel #4
0
class QTCreateInstrumentFrame(gtk.VBox):
    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)

        self._argument_table = ArgumentTable(2, 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)

        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()

    def _dropdown_changed_cb(self, widget):
        type_name = self._type_dropdown.get_typename()
        if type_name is None:
            args = None
        else:
            args = self._instruments.get_type_arguments(type_name)
        self._argument_table.set_arg_spec(args)

        self._update_add_button_sensitivity()

    def _add_clicked_cb(self, widget):
        name = self._name_entry.get_text()
        typename = self._type_dropdown.get_typename()
        args = self._argument_table.get_args()
        logging.debug("Creating %s as %s, **args: %r", name, typename, args)
        ins = qt.instruments.create(name, typename, **args)
        if ins is not None:
            self._name_entry.set_text('')
            self._type_dropdown.select_none_type()

    def _name_changed_cb(self, widget):
        self._update_add_button_sensitivity()

    def _update_add_button_sensitivity(self):
        typename = self._type_dropdown.get_typename()
        namelen = len(self._name_entry.get_text())

        if typename is not None and typename != '' and namelen > 0:
            self._add_button.set_sensitive(True)
        else:
            self._add_button.set_sensitive(False)