예제 #1
0
 def addToGrid(self, grid, v_index, remove_callback):
     name_e = DevOptionGUI("",
                           "string",
                           self.setName,
                           default=self.name,
                           doLabel=False)
     grid.attach(name_e.getComponent(), 0, v_index, 1, 1)
     unit_e = DevOptionGUI("",
                           "string",
                           self.setUnit,
                           default=str(self.unit),
                           doLabel=False)
     grid.attach(unit_e.getComponent(), 1, v_index, 1, 1)
     mix_e = DevOptionGUI("",
                          "float",
                          self.setMin,
                          default="",
                          doLabel=False)
     max_e = DevOptionGUI("",
                          "float",
                          self.setMax,
                          default="",
                          doLabel=False)
     grid.attach(mix_e.getComponent(), 2, v_index, 1, 1)
     grid.attach(max_e.getComponent(), 3, v_index, 1, 1)
     remove_b = Gtk.Button("Remove Axis")
     remove_b.connect("clicked", lambda _: remove_callback())
     grid.attach(remove_b, 4, v_index, 1, 1)
예제 #2
0
    def addToGrid(self, grid, v_index, remove_callback):
        grid.attach(
            Gtk.Label(self.channel.parent.name + ": " + self.channel.name), 0,
            v_index, 1, 1)

        y_axes_sel = Gtk.ComboBoxText()
        for axis in self.y_axes:
            y_axes_sel.append_text("%s [%s]" % (axis.name, str(axis.unit)))

        y_axes_sel.connect("changed", self.axisSelected)

        #check if our previous selection is in menu, and, if so, select it
        #else, choose axis 0
        if self.y_axis in self.y_axes:
            index = self.y_axes.index(self.y_axis)
            y_axes_sel.set_active(index)
        else:
            self.y_axis = self.y_axes[0]
            y_axes_sel.set_active(0)

        grid.attach(y_axes_sel, 1, v_index, 1, 1)

        color_b = Gtk.ColorButton()
        color_b.set_rgba(self.color)
        color_b.connect("color-set", self.setColor)
        grid.attach(color_b, 2, v_index, 1, 1)

        remove_b = Gtk.Button("Remove Source")
        remove_b.connect("clicked", lambda _: remove_callback())
        grid.attach(remove_b, 3, v_index, 1, 1)

        #now add attributes based on channel type
        h_index = 4
        if self.channel.isComplex():
            box = Gtk.HBox()
            box.pack_start(Gtk.Label("Complex Mode: "), False, False, 0)
            type_sel = Gtk.ComboBoxText()
            type_sel.append_text("Real Part")
            type_sel.append_text("Imaginary Part")
            type_sel.append_text("Angle")
            type_sel.append_text("Magnitude")

            if self.complexMode != -1:
                type_sel.set_active(self.complexMode)

            def setComplexType(widget):
                self.complexMode = widget.get_active()
                self.update_callback()

            type_sel.connect("changed", setComplexType)
            box.pack_start(type_sel, False, False, 0)
            grid.attach(box, h_index, v_index, 1, 1)
            h_index += 1
        for dim in self.channel.getAdditionalDims():
            if not dim in self.dimSelect:
                self.dimSelect[dim] = 0

            def makeSetDim(dim):
                def set(res):
                    self.dimSelect[dim] = res
                    self.update_callback()

                return set

            dim_input = DevOptionGUI("%s: " % dim,
                                     "int",
                                     makeSetDim(dim),
                                     doTypeLabel=False,
                                     default=self.dimSelect[dim])
            grid.attach(dim_input.getComponent(), h_index, v_index, 1, 1)
            h_index += 1