diff options
author | jblum | 2009-02-12 19:47:23 +0000 |
---|---|---|
committer | jblum | 2009-02-12 19:47:23 +0000 |
commit | d3d62764237a2834a8a4eb54934afba8c63999d9 (patch) | |
tree | 45d72759d94a27d1a33aa5acca1c3ac058b2055d /grc/src/platforms/base | |
parent | f962f54c6089f60fbd395464e6771701a85f57fd (diff) | |
download | gnuradio-d3d62764237a2834a8a4eb54934afba8c63999d9.tar.gz gnuradio-d3d62764237a2834a8a4eb54934afba8c63999d9.tar.bz2 gnuradio-d3d62764237a2834a8a4eb54934afba8c63999d9.zip |
port and type controller modify logic out of gui
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@10442 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'grc/src/platforms/base')
-rw-r--r-- | grc/src/platforms/base/Block.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/grc/src/platforms/base/Block.py b/grc/src/platforms/base/Block.py index 8cbcad5a7..bc9b58a5e 100644 --- a/grc/src/platforms/base/Block.py +++ b/grc/src/platforms/base/Block.py @@ -196,6 +196,42 @@ class Block(Element): except Exception, e: return "-------->\n%s: %s\n<--------"%(e, tmpl) ############################################## + # Controller Modify + ############################################## + def type_controller_modify(self, direction): + """ + Change the type controller. + @param direction +1 or -1 + @return true for change + """ + changed = False + type_param = None + for param in filter(lambda p: p.is_enum(), self.get_params()): + children = self.get_ports() + self.get_params() + #priority to the type controller + if param.get_key() in ' '.join(map(lambda p: p._type, children)): type_param = param + #use param if type param is unset + if not type_param: type_param = param + if type_param: + #try to increment the enum by direction + try: + keys = type_param.get_option_keys() + old_index = keys.index(type_param.get_value()) + new_index = (old_index + direction + len(keys))%len(keys) + type_param.set_value(keys[new_index]) + changed = True + except: pass + return changed + + def port_controller_modify(self, direction): + """ + Change the port controller. + @param direction +1 or -1 + @return true for change + """ + return False + + ############################################## ## Import/Export Methods ############################################## def export_data(self): |