summaryrefslogtreecommitdiff
path: root/grc/python
diff options
context:
space:
mode:
authorJohnathan Corgan <johnathan@corganlabs.com>2014-06-13 14:36:01 -0700
committerJohnathan Corgan <johnathan@corganlabs.com>2014-06-13 14:36:01 -0700
commitf3fbf453e08a490d6c610658ad6394e308c2a14e (patch)
tree6c9954f7b6ffbdd77c3772d2c5124d5dc392311f /grc/python
parent34ee3b7d45678dfcca221d03ca6d796a46e41288 (diff)
parentc138442d414168b681c0d4900906360a27b4c8c3 (diff)
Merge branch 'maint'
Diffstat (limited to 'grc/python')
-rw-r--r--grc/python/FlowGraph.py17
-rw-r--r--grc/python/flow_graph.tmpl8
2 files changed, 20 insertions, 5 deletions
diff --git a/grc/python/FlowGraph.py b/grc/python/FlowGraph.py
index bf98c7ab38..8573f33fc4 100644
--- a/grc/python/FlowGraph.py
+++ b/grc/python/FlowGraph.py
@@ -107,6 +107,23 @@ class FlowGraph(_FlowGraph, _GUIFlowGraph):
pads = filter(lambda b: b.get_key() == 'pad_sink', self.get_enabled_blocks())
return sorted(pads, lambda x, y: cmp(x.get_id(), y.get_id()))
+ def get_pad_port_global_key(self, port):
+ """
+ Get the key for a port of a pad source/sink to use in connect()
+ This takes into account that pad blocks may have multiple ports
+
+ Returns:
+ the key (str)
+ """
+ key_offset = 0
+ pads = self.get_pad_sources() if port.is_source() else self.get_pad_sinks()
+ for pad in pads:
+ if port.get_parent() == pad:
+ return str(key_offset + int(port.get_key()))
+ # assuming we have either only sources or sinks
+ key_offset += len(pad.get_ports())
+ return -1
+
def get_msg_pad_sources(self):
ps = self.get_pad_sources();
return filter(lambda b: b.get_param('type').get_evaluated() == 'message', ps);
diff --git a/grc/python/flow_graph.tmpl b/grc/python/flow_graph.tmpl
index 30a991eeda..52582384aa 100644
--- a/grc/python/flow_graph.tmpl
+++ b/grc/python/flow_graph.tmpl
@@ -181,10 +181,8 @@ gr.io_signaturev($(len($io_sigs)), $(len($io_sigs)), [$(', '.join($size_strs))])
## However, port names for IO pads should be self.
########################################################
#def make_port_sig($port)
- #if $port.get_parent().get_key() == 'pad_source'
-(self, $flow_graph.get_pad_sources().index($port.get_parent()))#slurp
- #elif $port.get_parent().get_key() == 'pad_sink'
-(self, $flow_graph.get_pad_sinks().index($port.get_parent()))#slurp
+ #if $port.get_parent().get_key() in ('pad_source', 'pad_sink')
+(self, $flow_graph.get_pad_port_global_key($port))#slurp
#else
(self.$port.get_parent().get_id(), $port.get_key())#slurp
#end if
@@ -235,7 +233,7 @@ gr.io_signaturev($(len($io_sigs)), $(len($io_sigs)), [$(', '.join($size_strs))])
#end for
########################################################
-# QT sink close method reimplementation
+## QT sink close method reimplementation
########################################################
#if $generate_options == 'qt_gui'
def closeEvent(self, event):