[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 08/16: grc: move generated start-up code in
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 08/16: grc: move generated start-up code into main(), whitespace fixes in generated code |
Date: |
Sat, 3 Oct 2015 19:14:11 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit 8777f25f9fed349bff8ffc30cd99ea1dc915d3ad
Author: Sebastian Koslowski <address@hidden>
Date: Wed Sep 23 16:18:55 2015 +0200
grc: move generated start-up code into main(), whitespace fixes in
generated code
---
grc/python/flow_graph.tmpl | 36 +++++++++++++++++++++---------------
1 file changed, 21 insertions(+), 15 deletions(-)
diff --git a/grc/python/flow_graph.tmpl b/grc/python/flow_graph.tmpl
index 3cc16e7..4e4e945 100644
--- a/grc/python/flow_graph.tmpl
+++ b/grc/python/flow_graph.tmpl
@@ -7,7 +7,7 @@
address@hidden imports the import statements
address@hidden flow_graph the flow_graph
address@hidden variables the variable blocks
address@hidden parameters the paramater blocks
address@hidden parameters the parameter blocks
address@hidden blocks the signal blocks
address@hidden connections the connections
address@hidden msgs the msg type connections
@@ -95,9 +95,9 @@ class $(class_name)(gr.top_block, Qt.QWidget):
Qt.QWidget.__init__(self)
self.setWindowTitle("$title")
try:
- self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
+ self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
except:
- pass
+ pass
self.top_scroll_layout = Qt.QVBoxLayout()
self.setLayout(self.top_scroll_layout)
self.top_scroll = Qt.QScrollArea()
@@ -258,22 +258,22 @@ gr.io_signaturev($(len($io_sigs)), $(len($io_sigs)),
[$(', '.join($size_strs))])
#include source=$connection_templates[($source.get_domain(),
$sink.get_domain())]
#end for
-
########################################################
## QT sink close method reimplementation
########################################################
#if $generate_options == 'qt_gui'
+
def closeEvent(self, event):
self.settings = Qt.QSettings("GNU Radio", "$class_name")
self.settings.setValue("geometry", self.saveGeometry())
event.accept()
#end if
-
########################################################
##Create Callbacks
## Write a set method for this variable that calls the callbacks
########################################################
#for $var in $parameters + $variables
+
#set $id = $var.get_id()
def get_$(id)(self):
return self.$id
@@ -291,7 +291,6 @@ gr.io_signaturev($(len($io_sigs)), $(len($io_sigs)), [$(',
'.join($size_strs))])
$indent($callback)
#end for
#end if
-
#end for
########################################################
##Create Main
@@ -314,24 +313,28 @@ $short_id#slurp
#end def
#if not $generate_options.startswith('hb')
-if __name__ == '__main__':
- parser = OptionParser(option_class=eng_option, usage="%prog: [options]")
+
+def main(top_block_cls=$(class_name)):
#set $params_eq_list = list()
+ #if $parameters
+ parser = OptionParser(option_class=eng_option, usage="%prog: [options]")
#for $param in $parameters
#set $type = $param.get_param('type').get_value()
#if $type
#silent $params_eq_list.append('%s=options.%s'%($param.get_id(),
$param.get_id()))
- parser.add_option("$make_short_id($param)",
"--$param.get_id().replace('_', '-')", dest="$param.get_id()", type="$type",
default=$make_default($type, $param),
+ parser.add_option(
+ "$make_short_id($param)", "--$param.get_id().replace('_', '-')",
dest="$param.get_id()", type="$type", default=$make_default($type, $param),
help="Set $($param.get_param('label').get_evaluated() or
$param.get_id()) [default=%default]")
#end if
#end for
(options, args) = parser.parse_args()
+ #end if
#if $flow_graph.get_option('realtime_scheduling')
if gr.enable_realtime_scheduling() != gr.RT_OK:
- print "Error: failed to enable realtime scheduling."
+ print "Error: failed to enable real-time scheduling."
#end if
#if $generate_options == 'wx_gui'
- tb = $(class_name)($(', '.join($params_eq_list)))
+ tb = top_block_cls($(', '.join($params_eq_list)))
#if $flow_graph.get_option('max_nouts')
tb.Run($flow_graph.get_option('run'), $flow_graph.get_option('max_nouts'))
#else
@@ -344,9 +347,9 @@ if __name__ == '__main__':
#elif $generate_options == 'qt_gui'
from distutils.version import StrictVersion
if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.0"):
-
Qt.QApplication.setGraphicsSystem(gr.prefs().get_string('qtgui','style','raster'))
+ Qt.QApplication.setGraphicsSystem(gr.prefs().get_string('qtgui',
'style', 'raster'))
qapp = Qt.QApplication(sys.argv)
- tb = $(class_name)($(', '.join($params_eq_list)))
+ tb = top_block_cls($(', '.join($params_eq_list)))
#if $flow_graph.get_option('run')
#if $flow_graph.get_option('max_nouts')
tb.start($flow_graph.get_option('max_nouts'))
@@ -368,9 +371,8 @@ if __name__ == '__main__':
sys.stderr.write("Monitor '{0}' does not have an enable ('en')
parameter.".format("tb.$m.get_id()"))
#end for
qapp.exec_()
- tb = None # to clean up Qt widgets
#elif $generate_options == 'no_gui'
- tb = $(class_name)($(', '.join($params_eq_list)))
+ tb = top_block_cls($(', '.join($params_eq_list)))
#set $run_options = $flow_graph.get_option('run_options')
#if $run_options == 'prompt'
#if $flow_graph.get_option('max_nouts')
@@ -398,4 +400,8 @@ if __name__ == '__main__':
#end for
tb.wait()
#end if
+
+
+if __name__ == '__main__':
+ main()
#end if
- [Commit-gnuradio] [gnuradio] 14/16: Merge remote-tracking branch 'mbr0wn/uhd/multi_uhd_fft', (continued)
- [Commit-gnuradio] [gnuradio] 14/16: Merge remote-tracking branch 'mbr0wn/uhd/multi_uhd_fft', git, 2015/10/08
- [Commit-gnuradio] [gnuradio] 12/16: Merge branch 'maint', git, 2015/10/08
- [Commit-gnuradio] [gnuradio] 07/16: grc: per-flowgraph custom run commands, git, 2015/10/08
- [Commit-gnuradio] [gnuradio] 03/16: uhd: uhd_fft now uses UHDApp, some bugfixes, git, 2015/10/08
- [Commit-gnuradio] [gnuradio] 10/16: grc: simple dialog for selecting QSS theme for QT GUI apps, git, 2015/10/08
- [Commit-gnuradio] [gnuradio] 16/16: Merge remote-tracking branch 'gnuradio-wg-grc/master_grcwg', git, 2015/10/08
- [Commit-gnuradio] [gnuradio] 11/16: grc: added param to set per-flow-graph QT-theme file, git, 2015/10/08
- [Commit-gnuradio] [gnuradio] 01/16: grc: Flowgraph complexity. Shows under options block when enabled., git, 2015/10/08
- [Commit-gnuradio] [gnuradio] 02/16: grc: pad comment boxes like blocks, git, 2015/10/08
- [Commit-gnuradio] [gnuradio] 06/16: grc: add File->New submenu with generate modes preset, Bar.py refactoring, git, 2015/10/08
- [Commit-gnuradio] [gnuradio] 08/16: grc: move generated start-up code into main(), whitespace fixes in generated code,
git <=
- [Commit-gnuradio] [gnuradio] 13/16: Merge branch 'maint', git, 2015/10/08
- [Commit-gnuradio] [gnuradio] 09/16: grc: flowgraph template: split arg parser from main(), git, 2015/10/08
- [Commit-gnuradio] [gnuradio] 05/16: grc: fixup Actions*.py, git, 2015/10/08
- [Commit-gnuradio] [gnuradio] 15/16: Merge remote-tracking branch 'pinkavaj/no-x86-dtv-fix-00', git, 2015/10/08