QT GUI Range variable_qtgui_range QT GUI Widgets from PyQt4 import Qt import PyQt4.Qwt5 as Qwt self.$(id) = $(id) = $value #set $win = 'self._%s_layout'%$id #if not $label() #set $label = '"%s"'%$id #end if ######################################################################## #if $widget() == "knob" ######################################################################## $win = Qt.QVBoxLayout() self._$(id)_knob = Qwt.QwtKnob() self._$(id)_knob.setRange($start, $stop, $step) self._$(id)_knob.setValue(self.$id) self._$(id)_knob.valueChanged.connect(self.set_$(id)) $(win).addWidget(self._$(id)_knob) self._$(id)_label = Qt.QLabel($label) self._$(id)_label.setAlignment(Qt.Qt.AlignTop | Qt.Qt.AlignHCenter) $(win).addWidget(self._$(id)_label) #end if ######################################################################## #if $widget() == "thermo" ######################################################################## $win = Qt.QVBoxLayout() self._$(id)_label = Qt.QLabel($label) self._$(id)_thermo = Qwt.QwtThermo() self._$(id)_thermo.setScalePosition(Qwt.QwtThermo.$orient.scalepos) self._$(id)_thermo.setRange($start, $stop) self._$(id)_thermo.setValue(self.$id) self._$(id)_thermo.$(orient.minfcn)($min_len) #if 'horizontal' in $orient().lower() self._$(id)_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) $(win).addWidget(self._$(id)_label) $(win).addWidget(self._$(id)_thermo) #elif 'vertical' in $orient().lower() self._$(id)_label.setAlignment(Qt.Qt.AlignTop) $(win).addWidget(self._$(id)_thermo) $(win).addWidget(self._$(id)_label) #end if #end if ######################################################################## #if $widget() == "counter" ######################################################################## $win = Qt.QHBoxLayout() $(win).addWidget(Qt.QLabel($label+": ")) self._$(id)_counter = Qwt.QwtCounter() self._$(id)_counter.setRange($start, $stop, $step) self._$(id)_counter.setNumButtons(2) self._$(id)_counter.setMinimumWidth($min_len) self._$(id)_counter.setValue(self.$id) $(win).addWidget(self._$(id)_counter) self._$(id)_counter.valueChanged.connect(self.set_$(id)) #end if ######################################################################## #if $widget() == "slider" ######################################################################## $win = Qt.QVBoxLayout() self._$(id)_label = Qt.QLabel($label) self._$(id)_slider = Qwt.QwtSlider(None, Qt.$orient, Qwt.QwtSlider.$orient.scalepos, Qwt.QwtSlider.BgSlot) self._$(id)_slider.setRange($start, $stop, $step) self._$(id)_slider.setValue(self.$id) self._$(id)_slider.$(orient.minfcn)($min_len) self._$(id)_slider.valueChanged.connect(self.set_$(id)) #if 'horizontal' in $orient().lower() self._$(id)_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) $(win).addWidget(self._$(id)_label) $(win).addWidget(self._$(id)_slider) #elif 'vertical' in $orient().lower() self._$(id)_label.setAlignment(Qt.Qt.AlignTop) $(win).addWidget(self._$(id)_slider) $(win).addWidget(self._$(id)_label) #end if #end if ######################################################################## #if $widget() == "counter_slider" ######################################################################## $win = Qt.QVBoxLayout() self._$(id)_tool_bar = Qt.QToolBar(self) $(win).addWidget(self._$(id)_tool_bar) self._$(id)_tool_bar.addWidget(Qt.QLabel($label+": ")) self._$(id)_counter = Qwt.QwtCounter() self._$(id)_counter.setRange($start, $stop, $step) self._$(id)_counter.setNumButtons(2) self._$(id)_counter.setValue(self.$id) self._$(id)_tool_bar.addWidget(self._$(id)_counter) self._$(id)_counter.valueChanged.connect(self.set_$(id)) self._$(id)_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._$(id)_slider.setRange($start, $stop, $step) self._$(id)_slider.setValue(self.$id) self._$(id)_slider.setMinimumWidth($min_len) self._$(id)_slider.valueChanged.connect(self.set_$(id)) $(win).addWidget(self._$(id)_slider) #end if $(gui_hint()($win)) self.set_$(id)($value) #if $widget() == "knob" self._$(id)_knob.setValue($id) #end if #if $widget() == "thermo" self._$(id)_thermo.setValue($id) #end if #if $widget() == "counter" self._$(id)_counter.setValue($id) #end if #if $widget() == "slider" self._$(id)_slider.setValue($id) #end if #if $widget() == "counter_slider" self._$(id)_counter.setValue($id) self._$(id)_slider.setValue($id) #end if Label label string #if $label() then 'none' else 'part'# Default Value value 50 real Start start 0 real Stop stop 100 real Step step 1 real Widget widget counter_slider enum part Orientation orient Qt.Horizontal enum #if $widget() in ("slider", "thermo") then 'part' else 'all'# Minimum Length min_len 200 int #if $widget().split('_')[0] in ("slider", "counter", "thermo") then 'part' else 'all'# GUI Hint gui_hint gui_hint part $start <= $value <= $stop $start < $stop This block creates a variable with a slider. \ Leave the label blank to use the variable id as the label. \ The value must be a real number. \ The value must be between the start and the stop. The GUI hint can be used to position the widget within the application. \ The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. \ Both the tab specification and the grid position are optional.