diff options
author | Josh Blum <josh@joshknows.com> | 2011-03-05 20:37:40 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-03-05 20:37:40 -0800 |
commit | 19c0865b4b6c94f86679151e9f52c99331b1f0b9 (patch) | |
tree | 1fdfb8610fe19c5cc3024c476217150197aeb0a6 | |
parent | 028f105b345c937f69aa5701e0de7761a2c6fcf3 (diff) |
qtgui-grc: moved slider to range, added knob and gui tweaks
-rw-r--r-- | gr-qtgui/grc/Makefile.am | 4 | ||||
-rw-r--r-- | gr-qtgui/grc/qtgui_range.xml | 184 | ||||
-rw-r--r-- | gr-qtgui/grc/qtgui_slider.xml | 125 |
3 files changed, 186 insertions, 127 deletions
diff --git a/gr-qtgui/grc/Makefile.am b/gr-qtgui/grc/Makefile.am index 3045a8779c..b3114268c5 100644 --- a/gr-qtgui/grc/Makefile.am +++ b/gr-qtgui/grc/Makefile.am @@ -27,7 +27,7 @@ dist_grcblocks_DATA = \ qtgui_check_box.xml \ qtgui_entry.xml \ qtgui_label.xml \ + qtgui_range.xml \ qtgui_sink_x.xml \ qtgui_tab_widget.xml \ - qtgui_chooser.xml \ - qtgui_slider.xml + qtgui_chooser.xml diff --git a/gr-qtgui/grc/qtgui_range.xml b/gr-qtgui/grc/qtgui_range.xml new file mode 100644 index 0000000000..12807ec84e --- /dev/null +++ b/gr-qtgui/grc/qtgui_range.xml @@ -0,0 +1,184 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Variable Range: +## ranged widgets like a slider or a knob +################################################### + --> +<block> + <name>QT GUI Range</name> + <key>variable_qtgui_range</key> + <category>QT GUI Widgets</category> + <import>from PyQt4 import Qt</import> + <import>import PyQt4.Qwt5 as Qwt</import> + <import>from gnuradio import eng_notation</import> + <var_make>self.$(id) = $(id) = $value</var_make> + <make>#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(None) +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, None) +self._$(id)_label.setAlignment(Qt.Qt.AlignTop | Qt.Qt.AlignHCenter) +$(win).addWidget(self._$(id)_label) +#end if +######################################################################## +#if $widget() == "counter" +######################################################################## +$win = Qt.QHBoxLayout() +$(win).addWidget(Qt.QLabel($label+": ", None)) +self._$(id)_counter = Qwt.QwtCounter(None) +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 = $(orient.layout)() +self._$(id)_slider = Qwt.QwtSlider(None, Qt.$orient, $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)) +$(win).addWidget(self._$(id)_slider) +self._$(id)_num = Qt.QLabel(eng_notation.num_to_str($id), None) +$(win).addWidget(self._$(id)_num) +#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+": ", None)) +self._$(id)_counter = Qwt.QwtCounter(None) +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))</make> + <callback>self.set_$(id)($value)</callback> + <callback>#if $widget() == "knob" +self._$(id)_knob.setValue($id) +#end if +#if $widget() == "counter" +self._$(id)_counter.setValue($id) +#end if +#if $widget() == "slider" +self._$(id)_slider.setValue($id) +self._$(id)_num.setText(eng_notation.num_to_str($id)) +#end if +#if $widget() == "counter_slider" +self._$(id)_counter.setValue($id) +self._$(id)_slider.setValue($id) +#end if</callback> + <param> + <name>Label</name> + <key>label</key> + <value></value> + <type>string</type> + <hide>#if $label() then 'none' else 'part'#</hide> + </param> + <param> + <name>Default Value</name> + <key>value</key> + <value>50</value> + <type>real</type> + </param> + <param> + <name>Start</name> + <key>start</key> + <value>0</value> + <type>real</type> + </param> + <param> + <name>Stop</name> + <key>stop</key> + <value>100</value> + <type>real</type> + </param> + <param> + <name>Step</name> + <key>step</key> + <value>1</value> + <type>real</type> + </param> + <param> + <name>Widget</name> + <key>widget</key> + <value>counter_slider</value> + <type>enum</type> + <hide>part</hide> + <option><name>Counter + Slider</name><key>counter_slider</key></option> + <option><name>Counter</name><key>counter</key></option> + <option><name>Slider</name><key>slider</key></option> + <option><name>Knob</name><key>knob</key></option> + </param> + <param> + <name>Orientation</name> + <key>orient</key> + <value>Qt.Horizontal</value> + <type>enum</type> + <hide>#if $widget() == "slider" then 'part' else 'all'#</hide> + <option> + <name>Horizontal</name> + <key>Qt.Horizontal</key> + <opt>scalepos:Qwt.QwtSlider.BottomScale</opt> + <opt>minfcn:setMinimumWidth</opt> + <opt>layout:Qt.QHBoxLayout</opt> + </option> + <option> + <name>Vertical</name> + <key>Qt.Vertical</key> + <opt>scalepos:Qwt.QwtSlider.RightScale</opt> + <opt>minfcn:setMinimumHeight</opt> + <opt>layout:Qt.QVBoxLayout</opt> + </option> + </param> + <param> + <name>Minimum Length</name> + <key>min_len</key> + <value>200</value> + <type>int</type> + <hide>#if $widget().split('_')[0] in ("slider", "counter") then 'part' else 'all'#</hide> + </param> + <param> + <name>GUI Hint</name> + <key>gui_hint</key> + <value></value> + <type>gui_hint</type> + <hide>part</hide> + </param> + <check>$start <= $value <= $stop</check> + <check>$start < $stop</check> + <doc> +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. + </doc> +</block> diff --git a/gr-qtgui/grc/qtgui_slider.xml b/gr-qtgui/grc/qtgui_slider.xml deleted file mode 100644 index 078e0df76c..0000000000 --- a/gr-qtgui/grc/qtgui_slider.xml +++ /dev/null @@ -1,125 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Variable Slider: -## a combined slider and text box form -################################################### - --> -<block> - <name>QT GUI Slider</name> - <key>variable_qtgui_slider</key> - <category>QT GUI Widgets</category> - <import>from PyQt4 import Qt</import> - <import>import PyQt4.Qwt5 as Qwt</import> - <var_make>self.$(id) = $(id) = $value</var_make> - <make>#set $win = '_%s_layout'%$id -$win = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom) -self._$(id)_tool_bar = Qt.QToolBar(self) -$(win).addWidget(self._$(id)_tool_bar) -#if not $label() - #set $label = '"%s"'%$id -#end if -self._$(id)_tool_bar.addWidget(Qt.QLabel($label+": ", None)) -#if int($widget.counter) -self._$(id)_counter = Qwt.QwtCounter(None) -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)) -#end if -#if int($widget.slider) -self._$(id)_slider = Qwt.QwtSlider(None) -self._$(id)_slider.setRange($start, $stop, $step) -self._$(id)_slider.setValue(self.$id) -self._$(id)_slider.setOrientation(Qt.$orient) -self._$(id)_slider.setScalePosition($orient.scalepos) -self._$(id)_slider.valueChanged.connect(self.set_$(id)) -$(win).addWidget(self._$(id)_slider) -#end if -$(gui_hint()($win))</make> - <callback>self.set_$(id)($value)</callback> - <callback>#if int($widget.counter) -self._$(id)_counter.setValue($id) -#end if -#if int($widget.slider) -self._$(id)_slider.setValue($id) -#end if</callback> - <param> - <name>Label</name> - <key>label</key> - <value></value> - <type>string</type> - <hide>#if $label() then 'none' else 'part'#</hide> - </param> - <param> - <name>Default Value</name> - <key>value</key> - <value>50</value> - <type>real</type> - </param> - <param> - <name>Start</name> - <key>start</key> - <value>0</value> - <type>real</type> - </param> - <param> - <name>Stop</name> - <key>stop</key> - <value>100</value> - <type>real</type> - </param> - <param> - <name>Step</name> - <key>step</key> - <value>1</value> - <type>real</type> - </param> - <param> - <name>Widget</name> - <key>widget</key> - <value>all</value> - <type>enum</type> - <hide>part</hide> - <option><name>Counter + Slider</name> <key>both</key> <opt>counter:1</opt><opt>slider:1</opt></option> - <option><name>Counter only</name> <key>counter</key> <opt>counter:1</opt><opt>slider:0</opt></option> - <option><name>Slider only</name> <key>slider</key> <opt>counter:0</opt><opt>slider:1</opt></option> - </param> - <param> - <name>Orientation</name> - <key>orient</key> - <value>Qt.Horizontal</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Horizontal</name> - <key>Qt.Horizontal</key> - <opt>scalepos:Qwt.QwtSlider.BottomScale</opt> - </option> - <option> - <name>Vertical</name> - <key>Qt.Vertical</key> - <opt>scalepos:Qwt.QwtSlider.RightScale</opt> - </option> - </param> - <param> - <name>GUI Hint</name> - <key>gui_hint</key> - <value></value> - <type>gui_hint</type> - <hide>part</hide> - </param> - <check>$start <= $value <= $stop</check> - <check>$start < $stop</check> - <doc> -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. - </doc> -</block> |