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_chooser.xml | 4 ++--
gr-qtgui/grc/qtgui_entry.xml | 2 +-
gr-qtgui/grc/qtgui_label.xml | 2 +-
gr-qtgui/grc/qtgui_range.xml | 29 ++++++++++++++++++++---------
gr-qtgui/grc/qtgui_tab_widget.xml | 2 +-
grc/blocks/variable_function_probe.xml | 7 +++++--
grc/python/flow_graph.tmpl | 1 +
7 files changed, 31 insertions(+), 16 deletions(-)
diff --git a/gr-qtgui/grc/qtgui_chooser.xml b/gr-qtgui/grc/qtgui_chooser.xml
index 6f405d99d..cb5090289 100644
--- a/gr-qtgui/grc/qtgui_chooser.xml
+++ b/gr-qtgui/grc/qtgui_chooser.xml
@@ -53,8 +53,8 @@ self._$(id)_labels = map(str, self._$(id)_options)
#if $widget() == 'combo_box'
#set $win = 'self._%s_tool_bar'%$id
$win = Qt.QToolBar(self)
-$(win).addWidget(Qt.QLabel($label+": ", None))
-self._$(id)_combo_box = Qt.QComboBox(None)
+$(win).addWidget(Qt.QLabel($label+": "))
+self._$(id)_combo_box = Qt.QComboBox()
$(win).addWidget(self._$(id)_combo_box)
for label in self._$(id)_labels: self._$(id)_combo_box.addItem(label)
self._$(id)_callback = lambda i: self._$(id)_combo_box.setCurrentIndex(self._$(id)_options.index(i))
diff --git a/gr-qtgui/grc/qtgui_entry.xml b/gr-qtgui/grc/qtgui_entry.xml
index 32c879420..1a98402a0 100644
--- a/gr-qtgui/grc/qtgui_entry.xml
+++ b/gr-qtgui/grc/qtgui_entry.xml
@@ -17,7 +17,7 @@ $win = Qt.QToolBar(self)
#if not $label()
#set $label = '"%s"'%$id
#end if
-$(win).addWidget(Qt.QLabel($label+": ", None))
+$(win).addWidget(Qt.QLabel($label+": "))
self._$(id)_line_edit = Qt.QLineEdit(str(self.$id))
self._$(id)_tool_bar.addWidget(self._$(id)_line_edit)
self._$(id)_line_edit.returnPressed.connect(
diff --git a/gr-qtgui/grc/qtgui_label.xml b/gr-qtgui/grc/qtgui_label.xml
index 96354688e..5049118c4 100644
--- a/gr-qtgui/grc/qtgui_label.xml
+++ b/gr-qtgui/grc/qtgui_label.xml
@@ -17,7 +17,7 @@ $win = Qt.QToolBar(self)
#if not $label()
#set $label = '"%s"'%$id
#end if
-$(win).addWidget(Qt.QLabel($label+": ", None))
+$(win).addWidget(Qt.QLabel($label+": "))
self._$(id)_label = Qt.QLabel(str(self.$id))
self._$(id)_tool_bar.addWidget(self._$(id)_label)
$(gui_hint()($win))
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
diff --git a/gr-qtgui/grc/qtgui_tab_widget.xml b/gr-qtgui/grc/qtgui_tab_widget.xml
index efdeaa19a..f90054109 100644
--- a/gr-qtgui/grc/qtgui_tab_widget.xml
+++ b/gr-qtgui/grc/qtgui_tab_widget.xml
@@ -10,7 +10,7 @@
QT GUI Widgets
from PyQt4 import Qt
#set $win = 'self.%s'%$id
-Qt.QTabWidget(None)
+Qt.QTabWidget()
#set $all_labels = [$label0, $label1, $label2, $label3, $label4][:int($num_tabs())]
#for i, label in enumerate($all_labels)
self.$(id)_widget_$(i) = Qt.QWidget()
diff --git a/grc/blocks/variable_function_probe.xml b/grc/blocks/variable_function_probe.xml
index 49f48fc89..269966c70 100644
--- a/grc/blocks/variable_function_probe.xml
+++ b/grc/blocks/variable_function_probe.xml
@@ -13,7 +13,9 @@
#slurp
def _$(id)_probe():
while True:
- self.set_$(id)(self.$(block_id()).$(function_name())($(function_args())))
+ val = self.$(block_id()).$(function_name())($(function_args()))
+ try: self.set_$(id)(val)
+ except AttributeError, e: pass
time.sleep(1.0/($poll_rate))
_$(id)_thread = threading.Thread(target=_$(id)_probe)
_$(id)_thread.daemon = True
@@ -57,7 +59,8 @@ Set the values for block ID, function name, and function args appropriately: \
Block ID should be the ID of another block in this flow graph. \
Function name should be the name of a class method on that block. \
Function args are the parameters passed into that function. \
-For a function with no arguments, leave function args blank.
+For a function with no arguments, leave function args blank. \
+When passing a string for the function arguments, quote the string literal: '"arg"'.
The values will used literally, and generated into the following form:
self.block_id.function_name(function_args)
diff --git a/grc/python/flow_graph.tmpl b/grc/python/flow_graph.tmpl
index 070ad7ed1..1aea58838 100644
--- a/grc/python/flow_graph.tmpl
+++ b/grc/python/flow_graph.tmpl
@@ -235,6 +235,7 @@ if __name__ == '__main__':
#elif $generate_options == 'qt_gui'
qapp = Qt.QApplication(sys.argv)
tb = $(class_name)($(', '.join($params_eq_list)))
+ tb.setWindowTitle("$title")
#if $flow_graph.get_option('run')
tb.start()
#end if
--
cgit