X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=gr-wxgui%2Fsrc%2Fpython%2Fcommon.py;h=09ce4471944d1d04b80aa4904618ee994376e473;hb=645ab0cfa4ab46e057ab4df74066ab434ad5b90a;hp=f355fd3ce6d91e4deecf19529702d672674f327c;hpb=69d09a30b38567c3ae33a227a3959aee43c721a7;p=debian%2Fgnuradio diff --git a/gr-wxgui/src/python/common.py b/gr-wxgui/src/python/common.py index f355fd3c..09ce4471 100644 --- a/gr-wxgui/src/python/common.py +++ b/gr-wxgui/src/python/common.py @@ -54,6 +54,26 @@ def bind_to_visible_event(win, callback): win.Bind(wx.EVT_ACTIVATE, handler) win = win.GetParent() +from gnuradio import gr + +def special_connect(source, sink, hb, win, size): + nulls = [gr.null_sink(size), gr.null_source(size)] + def callback(visible, init=False): + if not init: hb.lock() + if visible: + if not init: hb.disconnect(source, nulls[0]) + if not init: hb.disconnect(nulls[1], sink) + hb.connect(source, sink) + #hb.connect(nulls[1], nulls[0]) + else: + if not init: hb.disconnect(source, sink) + #if not init: hb.disconnect(nulls[1], nulls[0]) + hb.connect(source, nulls[0]) + hb.connect(nulls[1], sink) + if not init: hb.unlock() + callback(False, init=True) #initially connect + bind_to_visible_event(win, callback) + #A macro to apply an index to a key index_key = lambda key, i: "%s_%d"%(key, i+1)