def __init__(self, dev, data): super().__init__(dev, data) self.setName(data) self.addOption(DevOptionGUI("max", "float", lambda x: x, default=1.0)) self.addOption(DevOptionGUI("min", "float", lambda x: x, default=0.0)) self.addOption(DevOptionGUI("unit", "string", lambda x: x, default="V")) self.addOption( DevOptionGUI("x unit", "string", lambda x: x, default="s"))
def __init__(self, dev): super().__init__(self, dev) self.dev = dev self.setName('Real Scalar Channel in Time') self.addOption( DevOptionGUI('Min Value', 'float', lambda x: x, default=-1.0)) self.addOption( DevOptionGUI('Max Value', 'float', lambda x: x, default=1.0)) # NOTE: Sample Depth should actually be an integer but taking int(value) later works self.addOption( DevOptionGUI('Sample Depth', 'float', lambda x: x, default=20.0)) self.addOption( DevOptionGUI('Sampling Frequency [Hz]', 'float', lambda x: x, default=1.0))
def __init__(self, data): super().__init__(data) self.setName(data) self.addOption( DevOptionGUI("random device option", "string", lambda x: x)) self.addOption(DevOptionGUI("random float", "float", lambda x: x)) self.addOption( DevOptionGUI("random bool option", "bool", lambda x: x, default=True)) self.addOption(DevOptionGUI("random button", "button", lambda x: x)) self.addOption( DevOptionGUI("random int", "int", lambda x: x, default=-5)) #Add ten channels for i in range(10): self.addChannel(TestChannel(self, "channel %i" % i))
def __init__(self, dev): super().__init__(self, dev) self.dev = dev self.setName('Real Scalar Channel in Frequency') self.addOption( DevOptionGUI('Min Value', 'float', lambda x: x, default=-1.0)) self.addOption( DevOptionGUI('Max Value', 'float', lambda x: x, default=1.0)) self.addOption( DevOptionGUI('Start Frequency [Hz]', 'float', lambda x: x, default=1.0)) self.addOption( DevOptionGUI('Stop Frequency [Hz]', 'float', lambda x: x, default=100.0)) # NOTE: Frequency Stpes should actually be an integer but taking int(value) later works self.addOption( DevOptionGUI('Frequency Steps', 'float', lambda x: x, default=20))
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
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)