diff options
author | Josh Blum | 2011-03-01 13:03:36 -0800 |
---|---|---|
committer | Josh Blum | 2011-03-01 17:02:07 -0800 |
commit | a09e0096cf717c137126cd5fb721c0331a1a8df6 (patch) | |
tree | 37b128fd5e87499658f259392486c38478e0e1c3 | |
parent | 931332448227a6b509a9b39bb68044fa55d8b1cb (diff) | |
download | gnuradio-a09e0096cf717c137126cd5fb721c0331a1a8df6.tar.gz gnuradio-a09e0096cf717c137126cd5fb721c0331a1a8df6.tar.bz2 gnuradio-a09e0096cf717c137126cd5fb721c0331a1a8df6.zip |
grc-qtgui: creaded check box widget with qtgui, cleanup label code
-rw-r--r-- | gr-qtgui/grc/Makefile.am | 1 | ||||
-rw-r--r-- | gr-qtgui/grc/qtgui_check_box.xml | 83 | ||||
-rw-r--r-- | gr-qtgui/grc/qtgui_chooser.xml | 13 | ||||
-rw-r--r-- | gr-qtgui/grc/qtgui_slider.xml | 7 | ||||
-rw-r--r-- | gr-qtgui/grc/qtgui_static_text.xml | 8 | ||||
-rw-r--r-- | gr-qtgui/grc/qtgui_text_box.xml | 8 |
6 files changed, 99 insertions, 21 deletions
diff --git a/gr-qtgui/grc/Makefile.am b/gr-qtgui/grc/Makefile.am index 1153fc976..23e01a2c6 100644 --- a/gr-qtgui/grc/Makefile.am +++ b/gr-qtgui/grc/Makefile.am @@ -24,6 +24,7 @@ include $(top_srcdir)/Makefile.common grcblocksdir = $(grc_blocksdir) dist_grcblocks_DATA = \ + qtgui_check_box.xml \ qtgui_sink_x.xml \ qtgui_static_text.xml \ qtgui_tab_widget.xml \ diff --git a/gr-qtgui/grc/qtgui_check_box.xml b/gr-qtgui/grc/qtgui_check_box.xml new file mode 100644 index 000000000..95f4f968a --- /dev/null +++ b/gr-qtgui/grc/qtgui_check_box.xml @@ -0,0 +1,83 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Variable Check Box: +## a gui check box form +################################################### + --> +<block> + <name>QT GUI Check Box</name> + <key>variable_qtgui_check_box</key> + <category>QT GUI Widgets</category> + <import>from PyQt4 import Qt</import> + <var_make>self.$(id) = $(id) = $value</var_make> + <make>#set $win = '_%s_check_box'%$id +#if not $label() + #set $label = '"%s"'%$id +#end if +$win = Qt.QCheckBox($label) +self._$(id)_choices = {True: $true, False: $false} +self._$(id)_choices_inv = dict((v,k) for k,v in self._$(id)_choices.iteritems()) +self._$(id)_callback = lambda i: $(win).setChecked(self._$(id)_choices_inv[i]) +self._$(id)_callback(self.$id) +$(win).stateChanged.connect(lambda i: self.set_$(id)(self._$(id)_choices[bool(i)])) +$(gui_hint()($win))</make> + <callback>self.set_$(id)($value)</callback> + <callback>self._$(id)_callback($id)</callback> + <param> + <name>Label</name> + <key>label</key> + <value></value> + <type>string</type> + <hide>#if $label() then 'none' else 'part'#</hide> + </param> + <param> + <name>Type</name> + <key>type</key> + <value>int</value> + <type>enum</type> + <hide>part</hide> + <option><name>Float</name><key>real</key><opt>conv:float</opt></option> + <option><name>Integer</name><key>int</key><opt>conv:int</opt></option> + <option><name>String</name><key>string</key><opt>conv:str</opt></option> + <option><name>Boolean</name><key>bool</key><opt>conv:bool</opt></option> + <option><name>Any</name><key>raw</key><opt>conv:eval</opt></option> + </param> + <param> + <name>Default Value</name> + <key>value</key> + <value>True</value> + <type>$type</type> + </param> + <param> + <name>True</name> + <key>true</key> + <value>True</value> + <type>$type</type> + </param> + <param> + <name>False</name> + <key>false</key> + <value>False</value> + <type>$type</type> + </param> + <param> + <name>GUI Hint</name> + <key>gui_hint</key> + <value></value> + <type>gui_hint</type> + <hide>part</hide> + </param> + <check>$value in ($true, $false)</check> + <doc> +This block creates a variable check box. \ +Leave the label blank to use the variable id as the label. + +A check box selects between two values of similar type. \ +Te values do not necessarily need to be of boolean type. + +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_chooser.xml b/gr-qtgui/grc/qtgui_chooser.xml index 5f383949e..0d95c7cda 100644 --- a/gr-qtgui/grc/qtgui_chooser.xml +++ b/gr-qtgui/grc/qtgui_chooser.xml @@ -14,6 +14,9 @@ <make>#slurp #set $all_options = [$option0, $option1, $option2, $option3, $option4][:int($num_opts())] #set $all_labels = [$label0, $label1, $label2, $label3, $label4][:int($num_opts())] +#if not $label() + #set $label = '"%s"'%$id +#end if ######################################################################## ## Create the options list ######################################################################## @@ -50,11 +53,7 @@ self._$(id)_labels = map(str, self._$(id)_options) #if $widget() == 'combo_box' #set $win = 'self._%s_tool_bar'%$id $win = Qt.QToolBar(self) -#if $label() $(win).addWidget(Qt.QLabel($label+" ", None)) -#else -$(win).addWidget(Qt.QLabel("$id ", None)) -#end if self._$(id)_combo_box = Qt.QComboBox(None) $(win).addWidget(self._$(id)_combo_box) for label in self._$(id)_labels: self._$(id)_combo_box.addItem(label) @@ -67,12 +66,8 @@ self._$(id)_combo_box.currentIndexChanged.connect( ## Create the radio buttons ######################################################################## #if $widget() == 'radio_buttons' -#set $win = 'self._%s_radio_group'%$id -#if $label() +#set $win = 'self._%s_group_box'%$id $win = Qt.QGroupBox($label) -#else -$win = Qt.QGroupBox("$id") -#end if self._$(id)_box = $(orient)() self._$(id)_button_group = Qt.QButtonGroup() $(win).setLayout(self._$(id)_box) diff --git a/gr-qtgui/grc/qtgui_slider.xml b/gr-qtgui/grc/qtgui_slider.xml index 68000fa2f..e29123878 100644 --- a/gr-qtgui/grc/qtgui_slider.xml +++ b/gr-qtgui/grc/qtgui_slider.xml @@ -16,11 +16,10 @@ $win = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom) self._$(id)_tool_bar = Qt.QToolBar(self) $(win).addWidget(self._$(id)_tool_bar) -#if $label() -self._$(id)_tool_bar.addWidget(Qt.QLabel($label, None)) -#else -self._$(id)_tool_bar.addWidget(Qt.QLabel("$id", None)) +#if not $label() + #set $label = '"%s"'%$id #end if +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) diff --git a/gr-qtgui/grc/qtgui_static_text.xml b/gr-qtgui/grc/qtgui_static_text.xml index 92346b071..f20bf7e69 100644 --- a/gr-qtgui/grc/qtgui_static_text.xml +++ b/gr-qtgui/grc/qtgui_static_text.xml @@ -13,11 +13,10 @@ <var_make>self.$(id) = $(id) = $value</var_make> <make>#set $win = 'self._%s_tool_bar'%$id $win = Qt.QToolBar(self) -#if $label() -$(win).addWidget(Qt.QLabel($label+" ", None)) -#else -$(win).addWidget(Qt.QLabel("$id ", None)) +#if not $label() + #set $label = '"%s"'%$id #end if +$(win).addWidget(Qt.QLabel($label+" ", None)) self._$(id)_label = Qt.QLabel(str(self.$id)) self._$(id)_tool_bar.addWidget(self._$(id)_label) $(gui_hint()($win))</make> @@ -39,6 +38,7 @@ $(gui_hint()($win))</make> <option><name>Float</name><key>real</key><opt>conv:float</opt></option> <option><name>Integer</name><key>int</key><opt>conv:int</opt></option> <option><name>String</name><key>string</key><opt>conv:str</opt></option> + <option><name>Boolean</name><key>bool</key><opt>conv:bool</opt></option> <option><name>Any</name><key>raw</key><opt>conv:eval</opt></option> </param> <param> diff --git a/gr-qtgui/grc/qtgui_text_box.xml b/gr-qtgui/grc/qtgui_text_box.xml index 4fd961f55..0d7fe36ee 100644 --- a/gr-qtgui/grc/qtgui_text_box.xml +++ b/gr-qtgui/grc/qtgui_text_box.xml @@ -13,11 +13,10 @@ <var_make>self.$(id) = $(id) = $value</var_make> <make>#set $win = 'self._%s_tool_bar'%$id $win = Qt.QToolBar(self) -#if $label() -$(win).addWidget(Qt.QLabel($label+" ", None)) -#else -$(win).addWidget(Qt.QLabel("$id ", None)) +#if not $label() + #set $label = '"%s"'%$id #end if +$(win).addWidget(Qt.QLabel($label+" ", None)) self._$(id)_line_edit = Qt.QLineEdit(str(self.$id)) self._$(id)_tool_bar.addWidget(self._$(id)_line_edit) self._$(id)_line_edit.returnPressed.connect( @@ -41,6 +40,7 @@ $(gui_hint()($win))</make> <option><name>Float</name><key>real</key><opt>conv:float</opt></option> <option><name>Integer</name><key>int</key><opt>conv:int</opt></option> <option><name>String</name><key>string</key><opt>conv:str</opt></option> + <option><name>Boolean</name><key>bool</key><opt>conv:bool</opt></option> <option><name>Any</name><key>raw</key><opt>conv:eval</opt></option> </param> <param> |