From 19c0865b4b6c94f86679151e9f52c99331b1f0b9 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 5 Mar 2011 20:37:40 -0800 Subject: qtgui-grc: moved slider to range, added knob and gui tweaks --- gr-qtgui/grc/qtgui_range.xml | 184 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 gr-qtgui/grc/qtgui_range.xml (limited to 'gr-qtgui/grc/qtgui_range.xml') diff --git a/gr-qtgui/grc/qtgui_range.xml b/gr-qtgui/grc/qtgui_range.xml new file mode 100644 index 000000000..12807ec84 --- /dev/null +++ b/gr-qtgui/grc/qtgui_range.xml @@ -0,0 +1,184 @@ + + + + QT GUI Range + variable_qtgui_range + QT GUI Widgets + from PyQt4 import Qt + import PyQt4.Qwt5 as Qwt + from gnuradio import eng_notation + 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(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)) + self.set_$(id)($value) + #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 + + 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() == "slider" then 'part' else 'all'# + + + + + Minimum Length + min_len + 200 + int + #if $widget().split('_')[0] in ("slider", "counter") 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. + + -- cgit From 51bcf966e09e15bd97822608b236f02fd379ea87 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 7 Mar 2011 13:16:19 -0800 Subject: qtgui-grc: added read-only thermo widget to range block --- gr-qtgui/grc/qtgui_range.xml | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) (limited to 'gr-qtgui/grc/qtgui_range.xml') diff --git a/gr-qtgui/grc/qtgui_range.xml b/gr-qtgui/grc/qtgui_range.xml index 12807ec84..4d28de223 100644 --- a/gr-qtgui/grc/qtgui_range.xml +++ b/gr-qtgui/grc/qtgui_range.xml @@ -21,21 +21,33 @@ #if $widget() == "knob" ######################################################################## $win = Qt.QVBoxLayout() -self._$(id)_knob = Qwt.QwtKnob(None) +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, None) +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 = $(orient.layout)() +$(win).addWidget(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) +$(win).addWidget(self._$(id)_thermo) +#end if +######################################################################## #if $widget() == "counter" ######################################################################## $win = Qt.QHBoxLayout() -$(win).addWidget(Qt.QLabel($label+": ", None)) -self._$(id)_counter = Qwt.QwtCounter(None) +$(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) @@ -47,13 +59,13 @@ self._$(id)_counter.valueChanged.connect(self.set_$(id)) #if $widget() == "slider" ######################################################################## $win = $(orient.layout)() -self._$(id)_slider = Qwt.QwtSlider(None, Qt.$orient, $orient.scalepos, Qwt.QwtSlider.BgSlot) +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)) $(win).addWidget(self._$(id)_slider) -self._$(id)_num = Qt.QLabel(eng_notation.num_to_str($id), None) +self._$(id)_num = Qt.QLabel(eng_notation.num_to_str($id)) $(win).addWidget(self._$(id)_num) #end if ######################################################################## @@ -62,8 +74,8 @@ $(win).addWidget(self._$(id)_num) $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)_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) @@ -81,6 +93,9 @@ $(gui_hint()($win)) #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 @@ -133,24 +148,25 @@ self._$(id)_slider.setValue($id) + Orientation orient Qt.Horizontal enum - #if $widget() == "slider" then 'part' else 'all'# + #if $widget() in ("slider", "thermo") then 'part' else 'all'# @@ -160,7 +176,7 @@ self._$(id)_slider.setValue($id) min_len 200 int - #if $widget().split('_')[0] in ("slider", "counter") then 'part' else 'all'# + #if $widget().split('_')[0] in ("slider", "counter", "thermo") then 'part' else 'all'# GUI Hint -- cgit From 9121b75d68a0c90deee814edffe387480b52019b Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 7 Mar 2011 18:40:57 -0800 Subject: qtgui-grc: minor tweaks to the various things --- gr-qtgui/grc/qtgui_range.xml | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'gr-qtgui/grc/qtgui_range.xml') diff --git a/gr-qtgui/grc/qtgui_range.xml b/gr-qtgui/grc/qtgui_range.xml index 4d28de223..6b0555f98 100644 --- a/gr-qtgui/grc/qtgui_range.xml +++ b/gr-qtgui/grc/qtgui_range.xml @@ -11,7 +11,6 @@ QT GUI Widgets from PyQt4 import Qt import PyQt4.Qwt5 as Qwt - from gnuradio import eng_notation self.$(id) = $(id) = $value #set $win = 'self._%s_layout'%$id #if not $label() @@ -33,14 +32,22 @@ $(win).addWidget(self._$(id)_label) ######################################################################## #if $widget() == "thermo" ######################################################################## -$win = $(orient.layout)() -$(win).addWidget(Qt.QLabel($label)) +$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" @@ -58,15 +65,22 @@ self._$(id)_counter.valueChanged.connect(self.set_$(id)) ######################################################################## #if $widget() == "slider" ######################################################################## -$win = $(orient.layout)() +$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) -self._$(id)_num = Qt.QLabel(eng_notation.num_to_str($id)) -$(win).addWidget(self._$(id)_num) +#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" @@ -101,7 +115,6 @@ 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) @@ -161,14 +174,12 @@ self._$(id)_slider.setValue($id) Qt.Horizontal scalepos:BottomScale minfcn:setMinimumWidth - layout:Qt.QHBoxLayout -- cgit