From ec7bdb4c93c8046b7d80bdad9b151c990946b181 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 14 Apr 2010 12:31:19 -0700 Subject: added to uhd grc files, also removed warning for grc generator with uhd blocks --- grc/python/Generator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'grc/python') diff --git a/grc/python/Generator.py b/grc/python/Generator.py index acd98ef84..d53802bef 100644 --- a/grc/python/Generator.py +++ b/grc/python/Generator.py @@ -58,7 +58,7 @@ class Generator(object): def write(self): #do throttle warning all_keys = ' '.join(map(lambda b: b.get_key(), self._flow_graph.get_enabled_blocks())) - if ('usrp' not in all_keys) and ('audio' not in all_keys) and ('throttle' not in all_keys) and self._generate_options != 'hb': + if ('usrp' not in all_keys) and ('uhd' not in all_keys) and ('audio' not in all_keys) and ('throttle' not in all_keys) and self._generate_options != 'hb': Messages.send_warning('''\ This flow graph may not have flow control: no audio or usrp blocks found. \ Add a Misc->Throttle block to your flow graph to avoid CPU congestion.''') -- cgit From 7ed83c72dbd079a50a421661a874c3ac94a34bd6 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 5 Dec 2010 17:21:07 -0500 Subject: grc: added qtgui support to grc (just added sink) --- grc/python/flow_graph.tmpl | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'grc/python') diff --git a/grc/python/flow_graph.tmpl b/grc/python/flow_graph.tmpl index a1a9308aa..676da33b4 100644 --- a/grc/python/flow_graph.tmpl +++ b/grc/python/flow_graph.tmpl @@ -59,6 +59,12 @@ class $(class_name)(grc_wxgui.top_block_gui): _icon_path = "$icon.get_filename()" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) #end if +#elif $generate_options == 'qt_gui' +class $(class_name)(gr.top_block): + + def __init__($param_str): + gr.top_block.__init__(self, "$title") + self.qapp = QtGui.QApplication(sys.argv) #elif $generate_options == 'no_gui' class $(class_name)(gr.top_block): @@ -242,6 +248,9 @@ if __name__ == '__main__': tb = $(class_name)($(', '.join($params_eq_list))) #if $generate_options == 'wx_gui' tb.Run($flow_graph.get_option('run')) + #elif $generate_options == 'qt_gui' + tb.start() + tb.qapp.exec_() #elif $generate_options == 'no_gui' #set $run_options = $flow_graph.get_option('run_options') #if $run_options == 'prompt' -- cgit From 9ae8997e5f682bc16e58c0a0bba21794dbd705c5 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 6 Dec 2010 22:46:39 -0500 Subject: qtgui: created a forms module with a slider and text box, implemented in grc --- grc/python/flow_graph.tmpl | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'grc/python') diff --git a/grc/python/flow_graph.tmpl b/grc/python/flow_graph.tmpl index 676da33b4..108e15ca0 100644 --- a/grc/python/flow_graph.tmpl +++ b/grc/python/flow_graph.tmpl @@ -60,11 +60,12 @@ class $(class_name)(grc_wxgui.top_block_gui): self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) #end if #elif $generate_options == 'qt_gui' -class $(class_name)(gr.top_block): +class $(class_name)(gr.top_block, QtGui.QWidget): def __init__($param_str): gr.top_block.__init__(self, "$title") - self.qapp = QtGui.QApplication(sys.argv) + QtGui.QWidget.__init__(self) + self.layout = QtGui.QBoxLayout(QtGui.QBoxLayout.TopToBottom, self) #elif $generate_options == 'no_gui' class $(class_name)(gr.top_block): @@ -245,15 +246,19 @@ if __name__ == '__main__': if gr.enable_realtime_scheduling() != gr.RT_OK: print "Error: failed to enable realtime scheduling." #end if - tb = $(class_name)($(', '.join($params_eq_list))) #if $generate_options == 'wx_gui' + tb = $(class_name)($(', '.join($params_eq_list))) tb.Run($flow_graph.get_option('run')) #elif $generate_options == 'qt_gui' + qapp = QtGui.QApplication(sys.argv) + tb = $(class_name)($(', '.join($params_eq_list))) tb.start() - tb.qapp.exec_() + tb.show() + qapp.exec_() #elif $generate_options == 'no_gui' #set $run_options = $flow_graph.get_option('run_options') #if $run_options == 'prompt' + tb = $(class_name)($(', '.join($params_eq_list))) tb.start() raw_input('Press Enter to quit: ') tb.stop() -- cgit From e30f0a7ca02801732ad7a25ab83e1d27dc45c6ce Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 20 Jan 2011 22:31:31 -0800 Subject: grc: added tabbed widget in qtgui for grc created gui_hint type to handle tab descriptor + position markup, and to handle the generation of the name of the parent widget. No support python modules required in gr-qtgui. --- grc/python/Generator.py | 4 ++++ grc/python/Param.py | 25 ++++++++++++++++++++++++- grc/python/flow_graph.tmpl | 13 +++++++++---- 3 files changed, 37 insertions(+), 5 deletions(-) (limited to 'grc/python') diff --git a/grc/python/Generator.py b/grc/python/Generator.py index d53802bef..7d08b914b 100644 --- a/grc/python/Generator.py +++ b/grc/python/Generator.py @@ -100,6 +100,10 @@ Add a Misc->Throttle block to your flow graph to avoid CPU congestion.''') filter(lambda b: b.get_key() == 'notebook', blocks), lambda n: n.get_id(), lambda n: n.get_param('notebook').get_value(), ) + notebooks += expr_utils.sort_objects( + filter(lambda b: b.get_key() == 'qtgui_tab_widget', blocks), + lambda n: n.get_id(), lambda n: n.get_param('gui_hint').get_value(), + ) #list of regular blocks (all blocks minus the special ones) blocks = filter(lambda b: b not in (imports + parameters + variables + probes + notebooks), blocks) + probes #list of connections where each endpoint is enabled diff --git a/grc/python/Param.py b/grc/python/Param.py index 6dd008d1d..27258faab 100644 --- a/grc/python/Param.py +++ b/grc/python/Param.py @@ -99,7 +99,7 @@ class Param(_Param, _GUIParam): 'hex', 'string', 'bool', 'file_open', 'file_save', 'id', 'stream_id', - 'grid_pos', 'notebook', + 'grid_pos', 'notebook', 'gui_hint', 'import', ) @@ -354,6 +354,29 @@ class Param(_Param, _GUIParam): except: raise Exception, 'Stream ID "%s" is not found.'%v return v ######################### + # GUI Position/Hint + ######################### + elif t == 'gui_hint': + if ':' in v: tab, pos = v.split(':') + elif '@' in v: tab, pos = v, '' + else: tab, pos = '', v + + if '@' in tab: tab, index = tab.split('@') + else: index = '?' + + widget_str = ({ + (True, True): 'self.%(tab)s_grid_layout_%(index)s.addWidget(%(widget)s, %(pos)s)', + (True, False): 'self.%(tab)s_layout_%(index)s.addWidget(%(widget)s)', + (False, True): 'self.top_grid_layout.addWidget(%(widget)s, %(pos)s)', + (False, False): 'self.top_layout.addWidget(%(widget)s)', + }[bool(tab), bool(pos)])%{'tab': tab, 'index': index, 'widget': '%s', 'pos': pos} + + def gui_hint(ws, w): + if 'layout' in w: ws = ws.replace('addWidget', 'addLayout') + return ws%w + + return lambda w: gui_hint(widget_str, w) + ######################### # Grid Position Type ######################### elif t == 'grid_pos': diff --git a/grc/python/flow_graph.tmpl b/grc/python/flow_graph.tmpl index 108e15ca0..88049a9ef 100644 --- a/grc/python/flow_graph.tmpl +++ b/grc/python/flow_graph.tmpl @@ -60,12 +60,14 @@ class $(class_name)(grc_wxgui.top_block_gui): self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) #end if #elif $generate_options == 'qt_gui' -class $(class_name)(gr.top_block, QtGui.QWidget): +class $(class_name)(gr.top_block, Qt.QWidget): def __init__($param_str): gr.top_block.__init__(self, "$title") - QtGui.QWidget.__init__(self) - self.layout = QtGui.QBoxLayout(QtGui.QBoxLayout.TopToBottom, self) + Qt.QWidget.__init__(self) + self.top_layout = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self) + self.top_grid_layout = Qt.QGridLayout() + self.top_layout.addLayout(self.top_grid_layout) #elif $generate_options == 'no_gui' class $(class_name)(gr.top_block): @@ -203,6 +205,9 @@ self.$port.get_parent().get_id()#slurp ######################################################## #for $var in $parameters + $variables #set $id = $var.get_id() + def get_$(id)(self): + return self.$id + def set_$(id)(self, $id): self.$id = $id #for $callback in $var_id2cbs[$id] @@ -250,7 +255,7 @@ if __name__ == '__main__': tb = $(class_name)($(', '.join($params_eq_list))) tb.Run($flow_graph.get_option('run')) #elif $generate_options == 'qt_gui' - qapp = QtGui.QApplication(sys.argv) + qapp = Qt.QApplication(sys.argv) tb = $(class_name)($(', '.join($params_eq_list))) tb.start() tb.show() -- cgit From f0537a7da4571bd6aaab273a0588eaef04121648 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 21 Jan 2011 15:20:45 -0800 Subject: grc: moved wxgui blocks and python into gr-wxgui/grc Prefixed wxgui blocks with WX GUI in the block names. Added category to wxgui variables blocks (not in the main block tree.xml) --- grc/python/Platform.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'grc/python') diff --git a/grc/python/Platform.py b/grc/python/Platform.py index 04db0b9b0..ec3f94096 100644 --- a/grc/python/Platform.py +++ b/grc/python/Platform.py @@ -1,5 +1,5 @@ """ -Copyright 2008, 2009, 2010 Free Software Foundation, Inc. +Copyright 2008, 2009, 2010, 2011 Free Software Foundation, Inc. This file is part of GNU Radio GNU Radio Companion is free software; you can redistribute it and/or -- cgit From 47f621a14c9a6e3696155dd5a223da40bcb7721c Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 27 Feb 2011 23:18:11 -0800 Subject: grc: work on generator for gui flowgraphs to simplify generation generator does not differentiate between notebooks and controls, they are all block, but block are now sorted by variables present in the make also adjusted categories listed in the wx and qt widget related blocks --- grc/python/Generator.py | 28 ++++++++++++---------------- grc/python/Param.py | 2 +- grc/python/flow_graph.tmpl | 30 ++++-------------------------- 3 files changed, 17 insertions(+), 43 deletions(-) (limited to 'grc/python') diff --git a/grc/python/Generator.py b/grc/python/Generator.py index 7d08b914b..b669fa65a 100644 --- a/grc/python/Generator.py +++ b/grc/python/Generator.py @@ -1,5 +1,5 @@ """ -Copyright 2008, 2009, 2010 Free Software Foundation, Inc. +Copyright 2008-2011 Free Software Foundation, Inc. This file is part of GNU Radio GNU Radio Companion is free software; you can redistribute it and/or @@ -90,22 +90,20 @@ Add a Misc->Throttle block to your flow graph to avoid CPU congestion.''') imports = self._flow_graph.get_imports() variables = self._flow_graph.get_variables() parameters = self._flow_graph.get_parameters() - #list of variables with controls - controls = filter(lambda v: v.get_make(), variables) #list of blocks not including variables and imports and parameters and disabled - blocks = sorted(self._flow_graph.get_enabled_blocks(), lambda x, y: cmp(x.get_id(), y.get_id())) - probes = filter(lambda b: b.get_key().startswith('probe_'), blocks) #ensure probes are last in the block list - #get a list of notebooks and sort them according dependencies - notebooks = expr_utils.sort_objects( - filter(lambda b: b.get_key() == 'notebook', blocks), - lambda n: n.get_id(), lambda n: n.get_param('notebook').get_value(), - ) - notebooks += expr_utils.sort_objects( - filter(lambda b: b.get_key() == 'qtgui_tab_widget', blocks), - lambda n: n.get_id(), lambda n: n.get_param('gui_hint').get_value(), + def _get_block_sort_text(block): + code = block.get_make().replace(block.get_id(), ' ') + try: code += block.get_param('notebook').get_value() #older gui markup w/ wxgui + except: pass + try: code += block.get_param('gui_hint').get_value() #newer gui markup w/ qtgui + except: pass + return code + blocks = expr_utils.sort_objects( + self._flow_graph.get_enabled_blocks(), + lambda b: b.get_id(), _get_block_sort_text ) #list of regular blocks (all blocks minus the special ones) - blocks = filter(lambda b: b not in (imports + parameters + variables + probes + notebooks), blocks) + probes + blocks = filter(lambda b: b not in (imports + parameters), blocks) #list of connections where each endpoint is enabled connections = filter(lambda c: not c.is_msg(), self._flow_graph.get_enabled_connections()) messages = filter(lambda c: c.is_msg(), self._flow_graph.get_enabled_connections()) @@ -129,8 +127,6 @@ Add a Misc->Throttle block to your flow graph to avoid CPU congestion.''') 'imports': imports, 'flow_graph': self._flow_graph, 'variables': variables, - 'notebooks': notebooks, - 'controls': controls, 'parameters': parameters, 'blocks': blocks, 'connections': connections, diff --git a/grc/python/Param.py b/grc/python/Param.py index 27258faab..303ab3ed8 100644 --- a/grc/python/Param.py +++ b/grc/python/Param.py @@ -1,5 +1,5 @@ """ -Copyright 2008, 2009, 2010 Free Software Foundation, Inc. +Copyright 2008-2011 Free Software Foundation, Inc. This file is part of GNU Radio GNU Radio Companion is free software; you can redistribute it and/or diff --git a/grc/python/flow_graph.tmpl b/grc/python/flow_graph.tmpl index 88049a9ef..8757b5204 100644 --- a/grc/python/flow_graph.tmpl +++ b/grc/python/flow_graph.tmpl @@ -5,8 +5,6 @@ ##@param imports the import statements ##@param flow_graph the flow_graph ##@param variables the variable blocks -##@param notebooks a list of notebook blocks -##@param controls the variables with gui controls ##@param parameters the paramater blocks ##@param blocks the signal blocks ##@param connections the connections @@ -121,30 +119,6 @@ gr.io_signaturev($(len($io_sigs)), $(len($io_sigs)), [$(', '.join($size_strs))]) $indent($var.get_var_make()) #end for ######################################################## -##Create Notebooks -######################################################## -#if $notebooks - - $DIVIDER - # Notebooks - $DIVIDER -#end if -#for $notebook in $notebooks - $indent($notebook.get_make()) -#end for -######################################################## -##Create Controls -######################################################## -#if $controls - - $DIVIDER - # Controls - $DIVIDER -#end if -#for $ctrl in $controls - $indent($ctrl.get_make()) -#end for -######################################################## ##Create Message Queues ######################################################## #if $messages @@ -166,7 +140,11 @@ gr.io_signaturev($(len($io_sigs)), $(len($io_sigs)), [$(', '.join($size_strs))]) $DIVIDER #end if #for $blk in filter(lambda b: b.get_make(), $blocks) + #if $blk in $variables + $indent($blk.get_make()) + #else self.$blk.get_id() = $indent($blk.get_make()) + #end if #end for ######################################################## ##Create Connections -- cgit From fedf4fbc9d217926ecbb1917d3c995516d88a8a9 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 1 Mar 2011 18:18:53 -0800 Subject: qtgui-grc: enable start/stop control through qt widgets --- grc/python/flow_graph.tmpl | 2 ++ 1 file changed, 2 insertions(+) (limited to 'grc/python') diff --git a/grc/python/flow_graph.tmpl b/grc/python/flow_graph.tmpl index 8757b5204..854d83967 100644 --- a/grc/python/flow_graph.tmpl +++ b/grc/python/flow_graph.tmpl @@ -235,7 +235,9 @@ if __name__ == '__main__': #elif $generate_options == 'qt_gui' qapp = Qt.QApplication(sys.argv) tb = $(class_name)($(', '.join($params_eq_list))) + #if $flow_graph.get_option('run') tb.start() + #end if tb.show() qapp.exec_() #elif $generate_options == 'no_gui' -- cgit From 028f105b345c937f69aa5701e0de7761a2c6fcf3 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 4 Mar 2011 09:08:37 -0800 Subject: qtgui-grc: use a vboxlayout for the top_layout --- grc/python/flow_graph.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'grc/python') diff --git a/grc/python/flow_graph.tmpl b/grc/python/flow_graph.tmpl index 854d83967..070ad7ed1 100644 --- a/grc/python/flow_graph.tmpl +++ b/grc/python/flow_graph.tmpl @@ -63,7 +63,7 @@ class $(class_name)(gr.top_block, Qt.QWidget): def __init__($param_str): gr.top_block.__init__(self, "$title") Qt.QWidget.__init__(self) - self.top_layout = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self) + self.top_layout = Qt.QVBoxLayout(self) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) #elif $generate_options == 'no_gui' -- 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 --- grc/python/flow_graph.tmpl | 1 + 1 file changed, 1 insertion(+) (limited to 'grc/python') 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 From c86acebd1ab6adf994f49dab1669fcbbb6324637 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 7 Mar 2011 23:52:40 -0800 Subject: qtgui-grc: added suport in main template for theme icon --- grc/python/flow_graph.tmpl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'grc/python') diff --git a/grc/python/flow_graph.tmpl b/grc/python/flow_graph.tmpl index 1aea58838..5aaa99793 100644 --- a/grc/python/flow_graph.tmpl +++ b/grc/python/flow_graph.tmpl @@ -63,6 +63,8 @@ class $(class_name)(gr.top_block, Qt.QWidget): def __init__($param_str): gr.top_block.__init__(self, "$title") Qt.QWidget.__init__(self) + self.setWindowTitle("$title") + self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) self.top_layout = Qt.QVBoxLayout(self) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) @@ -235,7 +237,6 @@ 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