diff options
author | Josh Blum | 2011-01-20 22:31:31 -0800 |
---|---|---|
committer | Josh Blum | 2011-03-01 17:02:06 -0800 |
commit | e30f0a7ca02801732ad7a25ab83e1d27dc45c6ce (patch) | |
tree | 4dce85c1bac97c380c243195ac8d05afa5afc7b2 /grc | |
parent | a284640decd1fd6634f35bd1e20fd69b9194a7b6 (diff) | |
download | gnuradio-e30f0a7ca02801732ad7a25ab83e1d27dc45c6ce.tar.gz gnuradio-e30f0a7ca02801732ad7a25ab83e1d27dc45c6ce.tar.bz2 gnuradio-e30f0a7ca02801732ad7a25ab83e1d27dc45c6ce.zip |
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.
Diffstat (limited to 'grc')
-rw-r--r-- | grc/blocks/options.xml | 2 | ||||
-rw-r--r-- | grc/python/Generator.py | 4 | ||||
-rw-r--r-- | grc/python/Param.py | 25 | ||||
-rw-r--r-- | grc/python/flow_graph.tmpl | 13 |
4 files changed, 38 insertions, 6 deletions
diff --git a/grc/blocks/options.xml b/grc/blocks/options.xml index 62ceeba0f..ed4d3c1d8 100644 --- a/grc/blocks/options.xml +++ b/grc/blocks/options.xml @@ -16,7 +16,7 @@ from grc_gnuradio import wxgui as grc_wxgui import wx #end if #if $generate_options() == 'qt_gui' -from PyQt4 import QtGui +from PyQt4 import Qt import sys #end if #if $generate_options() != 'hb' 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() |