diff options
author | Johnathan Corgan <johnathan@corganlabs.com> | 2017-09-25 12:36:58 -0700 |
---|---|---|
committer | Johnathan Corgan <johnathan@corganlabs.com> | 2017-09-25 12:36:58 -0700 |
commit | a2d1848efbcaa6c37887b95eb32dafcc15c39216 (patch) | |
tree | 05edf6ed88433e1bb6505de279f98fbf5a793532 /grc/core/generator/flow_graph.py.mako | |
parent | 831d993725fc6d58edb6a8e1008f8c84ec52f2d3 (diff) | |
parent | 6c85638cd5ec81140ec8bbd95bf23794e27b5c64 (diff) |
Merge remote-tracking branch 'skoslowski/python3' into python3
Diffstat (limited to 'grc/core/generator/flow_graph.py.mako')
-rw-r--r-- | grc/core/generator/flow_graph.py.mako | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/grc/core/generator/flow_graph.py.mako b/grc/core/generator/flow_graph.py.mako index 60b1f40569..b054f7aebf 100644 --- a/grc/core/generator/flow_graph.py.mako +++ b/grc/core/generator/flow_graph.py.mako @@ -90,6 +90,14 @@ class ${class_name}(gr.top_block, Qt.QWidget): self.restoreGeometry(self.settings.value("geometry")) except: pass +#elif $generate_options == 'bokeh_gui' + +class $(class_name)(gr.top_block): + def __init__(self, doc): + gr.top_block.__init__(self, "${title}") + self.doc = doc + self.plot_lst = [] + self.widget_lst = [] % elif generate_options == 'no_gui': class ${class_name}(gr.top_block): @@ -188,6 +196,22 @@ gr.io_signaturev(${len(io_sigs)}, ${len(io_sigs)}, [${', '.join(ize_strs)}]) ## (self.${blk.name}).set_max_output_buffer(${blk.params['maxoutbuf'].get_evaluated()}) ## % endif % endfor + +########################################################## +## Create a layout entry if not manually done for BokehGUI +########################################################## +%if generate_options == 'bokeh_gui' + if self.widget_lst: + input_t = bokehgui.BokehLayout.widgetbox(self.widget_lst) + widgetbox = bokehgui.BokehLayout.WidgetLayout(input_t) + widgetbox.set_layout(*(${flow_graph.get_option('placement')})) + list_obj = [widgetbox] + self.plot_lst + else: + list_obj = self.plot_lst + layout_t = bokehgui.BokehLayout.create_layout(list_obj, "${flow_graph.get_option('sizing_mode')}") + self.doc.add_root(layout_t) +% endif + % if connections: ${'##################################################'} @@ -333,6 +357,37 @@ def main(top_block_cls=${class_name}, options=None): sys.stderr.write("Monitor '{0}' does not have an enable ('en') parameter.".format("tb.${m.name}")) % endfor qapp.exec_() + #elif $generate_options == 'bokeh_gui' + serverProc, port = bokehgui.utils.create_server() + def killProc(signum, frame, tb): + tb.stop() + tb.wait() + serverProc.terminate() + serverProc.kill() + time.sleep(1) + try: + ${'#'} Define the document instance + doc = curdoc() + #if ${flow_graph.get_option('author')} + doc.title = "$title - ${flow_graph.get_option('author')}" + #else + doc.title = "${title}" + #end if + session = push_session(doc, session_id="${flow_graph.get_option('id')}", + url = "http://localhost:" + port + "/bokehgui") + ${'#'} Create Top Block instance + tb = top_block_cls(doc) + try: + tb.start() + signal.signal(signal.SIGTERM, functools.partial(killProc, tb=tb)) + session.loop_until_closed() + finally: + print("Exiting the simulation. Stopping Bokeh Server") + tb.stop() + tb.wait() + finally: + serverProc.terminate() + serverProc.kill() % elif generate_options == 'no_gui': tb = top_block_cls(${ ', '.join(params_eq_list) }) % if flow_graph.get_option('run_options') == 'prompt': |