summaryrefslogtreecommitdiff
path: root/grc/core
diff options
context:
space:
mode:
authorSebastian Koslowski <sebastian.koslowski@gmail.com>2017-08-30 20:17:52 +0200
committerSebastian Koslowski <sebastian.koslowski@gmail.com>2017-08-30 20:17:52 +0200
commit6a6eabc465c24e75f701b1e3d0033769ae76f736 (patch)
tree4058afdd804f1a48ab9ee3fb9660280cb5b828e5 /grc/core
parent1375fe38dd7ff6bcaffc25aed9b990a64cdb9c03 (diff)
parentc0f18d38456df2e0ad97bc90a2435601530d8ea1 (diff)
Merge branch 'master' into next
Diffstat (limited to 'grc/core')
-rw-r--r--grc/core/Platform.py4
-rw-r--r--grc/core/generator/flow_graph.tmpl55
-rw-r--r--grc/core/utils/__init__.py1
-rw-r--r--grc/core/utils/hide_bokeh_gui_options_if_not_installed.py28
4 files changed, 87 insertions, 1 deletions
diff --git a/grc/core/Platform.py b/grc/core/Platform.py
index b73dade2e8..3ff3700a6b 100644
--- a/grc/core/Platform.py
+++ b/grc/core/Platform.py
@@ -31,7 +31,7 @@ from .Block import Block
from .Port import Port
from .Param import Param
-from .utils import odict, extract_docs
+from .utils import odict, extract_docs, hide_bokeh_gui_options_if_not_installed
class Platform(Element):
@@ -173,6 +173,8 @@ class Platform(Element):
self._docstring_extractor.finish()
# self._docstring_extractor.wait()
+ hide_bokeh_gui_options_if_not_installed(self.blocks['options'])
+
def iter_xml_files(self):
"""Iterator for block descriptions and category trees"""
for block_path in self.config.block_paths:
diff --git a/grc/core/generator/flow_graph.tmpl b/grc/core/generator/flow_graph.tmpl
index 2adb555486..3bcf54eee4 100644
--- a/grc/core/generator/flow_graph.tmpl
+++ b/grc/core/generator/flow_graph.tmpl
@@ -114,6 +114,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'
@@ -220,6 +228,22 @@ gr.io_signaturev($(len($io_sigs)), $(len($io_sigs)), [$(', '.join($size_strs))])
#end if
#end if
#end for
+
+##########################################################
+## 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)
+#end if
+
########################################################
##Create Connections
## The port name should be the id of the parent block.
@@ -384,6 +408,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.get_id()"))
#end for
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)))
#set $run_options = $flow_graph.get_option('run_options')
diff --git a/grc/core/utils/__init__.py b/grc/core/utils/__init__.py
index 6b23da2723..2aed42d762 100644
--- a/grc/core/utils/__init__.py
+++ b/grc/core/utils/__init__.py
@@ -20,3 +20,4 @@ import epy_block_io
import extract_docs
from odict import odict
+from hide_bokeh_gui_options_if_not_installed import hide_bokeh_gui_options_if_not_installed
diff --git a/grc/core/utils/hide_bokeh_gui_options_if_not_installed.py b/grc/core/utils/hide_bokeh_gui_options_if_not_installed.py
new file mode 100644
index 0000000000..fc0141851a
--- /dev/null
+++ b/grc/core/utils/hide_bokeh_gui_options_if_not_installed.py
@@ -0,0 +1,28 @@
+# Copyright 2008-2017 Free Software Foundation, Inc.
+# This file is part of GNU Radio
+#
+# GNU Radio Companion is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# GNU Radio Companion is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+
+
+def hide_bokeh_gui_options_if_not_installed(options):
+ try:
+ import bokehgui
+ except ImportError:
+ generate_option = options.get_param('generate_options')
+ list_generate_option = generate_option.get_options()
+ for option in list_generate_option:
+ if option.get_key() == 'bokeh_gui':
+ list_generate_option.remove(option)
+ return