def init(self): time = [i / 100 for i in range(100)] with flx.VBox(): with flx.HBox(): flx.Label(text='Frequency:') self.slider1 = flx.Slider(min=1, max=10, value=5, flex=1) flx.Label(text='Phase:') self.slider2 = flx.Slider(min=0, max=6, value=0, flex=1) self.plot = flx.PlotWidget(flex=1, xdata=time, xlabel='time', ylabel='amplitude', title='a sinusoid')
def init(self): with flx.HBox(): with flx.VBox(flex=0, minsize=150): self.b1 = flx.RadioButton(text='Linear') self.b2 = flx.RadioButton(text='Basis') self.b3 = flx.RadioButton(text='Cardinal', checked=True) self.b4 = flx.RadioButton(text='Catmull Rom') self.b5 = flx.RadioButton(text='Lagrange') self.b6 = flx.RadioButton(text='Lanczos') flx.Widget(minsize=10) closed = flx.CheckBox(text='Closed') flx.Widget(minsize=10) self.tension = flx.Slider(min=-0.5, max=1, value=0.5, text=lambda: 'Tension: {value}') flx.Widget(flex=1) with flx.VBox(flex=1): flx.Label(text=GENERAL_TEXT, wrap=True, style='font-size: 12px;') self.explanation = flx.Label(text=CARDINAL_TEXT, wrap=True, style='font-size: 12px;') self.spline = SplineWidget(flex=1, closed=lambda: closed.checked, tension=lambda: self.tension.value)
def init(self, name, actuator_type, setpoint_topic, feedback_topic, cont_enable_topic, cont_setpoint_topic, cont_min, cont_max, is_angles=False): self.setpoint_topic = setpoint_topic self.cont_setpoint_topic = cont_setpoint_topic self.cont_enable_topic = cont_enable_topic self.is_angles = is_angles with flx.GroupWidget(title=name, flex=1): with flx.FormLayout(flex=1): flx.Label(text="Actuator setpoint") if is_angles: self.set_slider = flx.Slider(title="0", min=-1.6, max=1.6) self.set_slider2 = flx.Slider(title="0", min=-1.6, max=1.6) else: self.set_slider = flx.Slider(title="50", min=0, max=100, value=50) flx.Label(text="Controller setpoint") self.enable_cont = flx.CheckBox(title="Enabled") self.enable_cont.set_checked(True) self.cont_slider = flx.Slider(title="0", min=cont_min, max=cont_max, value=0) flx.Widget(minsize=20) self.announce_publish(setpoint_topic, actuator_type) self.announce_publish(cont_setpoint_topic, "std_msgs/Float64") self.announce_publish(cont_enable_topic, "std_msgs/Bool") self.subscribe(setpoint_topic, actuator_type, self._setpoint_callback) self.subscribe(cont_setpoint_topic, "std_msgs/Float64", self._cont_callback) self.subscribe(cont_enable_topic, "std_msgs/Bool", self._enable_callback) if is_angles: self.reaction(self._setpoint_slider, "set_slider2.user_done")
def init(self): # Put a label and some sliders deep in the hierarchy with flx.VBox(): self.label = flx.Label() with flx.HFix(flex=1): for j in range(2): with flx.VBox(flex=1): for i in range(5): flx.Slider(value=i / 5)
def init(self, name, topic, topic_type, actuator_settings): self.topic = topic with flx.GroupWidget(title=name, flex=1): with flx.FormLayout(flex=1): self.sliders = [] self.members = [] for settings in actuator_settings: self.sliders.append( flx.Slider(title=settings["name"], min=settings["min"], max=settings["max"], value=0)) if "type" in settings: self.members.append( (settings["member"], settings["type"])) else: self.members.append((settings["member"], "float")) #flx.Widget(minsize=10) self.announce_publish(topic, topic_type) self.subscribe(topic, topic_type, self._setpoint_callback)
def init(self): with flx.HFix(): flx.Widget(flex=1) with flx.VBox(flex=0, style='min-width:200px'): with flx.GroupWidget(title='Plot options'): flx.Label(text='Month') self.month = flx.ComboBox(options=months, selected_index=12, style='width: 100%') self.smoothing_label = flx.Label(text='Smoothing') self.smoothing = flx.Slider(max=20, step=2, text='{value} samples') flx.Widget(flex=3) with flx.VBox(flex=4): self.plot = flx.PlotWidget(flex=1, xdata=years, yrange=(-5, 20), title='Average monthly temperature', xlabel='year', ylabel=u'temperature (°C)') flx.Widget(flex=1)
def init(self, model): super().init() self.model = model times = [i / 20 for i in range(20)] with flx.VBox(): with flx.HBox(): with flx.VBox(): flx.Label(text='Settings', style='text-align:center;font-weight: bold;') with flx.HBox(flex=0): with flx.VBox(): flx.Label(style="text-align:right", text='VIN:') flx.Label(style="text-align:right", text='Controls Enabled:') flx.Label(style="text-align:right", text='Time:') flx.Label(style="text-align:right", text='ROS Vehicle Control Running:') flx.Label(style="text-align:right", text='Recording:') flx.Label(style="text-align:right", text='GPS Fix:') flx.Label(style="text-align:right", text='Battery Voltage:') flx.Label(style="text-align:right", text='Battery Capacity:') with flx.VBox(): self.labelVin = flx.Label(style="text-align:left", text=relay.vin) self.labelControls = flx.Label( style="text-align:left", text='False') self.labelTime = flx.Label(style="text-align:left", text='Not Set') #self.labelTime = flx.Label(style="text-align:left",text=lambda: self.root.store.time) self.labelVehicleControl = flx.Label( style="text-align:left", text=str(relay.vehicleControlRunning)) self.labelRecording = flx.Label( style="text-align:left", text=str(relay.pandaRecording)) self.labelGps = flx.Label(style="text-align:left", text=str(relay.pandaGps)) self.labelVoltage = flx.Label( style="text-align:left", text=str(relay.voltage)) self.labelCapacity = flx.Label( style="text-align:left", text=str(relay.capacity)) with flx.VBox(): self.b1 = flx.Button(text='Start') self.b2 = flx.Button(text='Stop') # self. with flx.VBox(): flx.Label(text='Plot', style='text-align:center;font-weight: bold;') with flx.HBox(): flx.Label(text='Time:') self.slider1 = flx.Slider(min=1, max=10, value=5, flex=1) flx.Label(text='Magnitude:') self.slider2 = flx.Slider(min=0, max=10, value=0, flex=1) self.plot = flx.PlotWidget(flex=1, xdata=times, xlabel='time', ylabel='Acc', title='Profile')
def init(self): self.amp = flx.Slider(title='Amplitude', max=2, value=1) self.freq = flx.Slider(title='Frequency', max=10, value=5) self.phase = flx.Slider(title='Phase', max=3, value=1)