@@ -38,7 +38,7 @@ import threading
38
38
39
39
## Call XInitThreads as the _very_ first thing.
40
40
## After some Qt import, it's too late
41
- #if $generate_options in ('wx_gui', 'qt_gui')
41
+ #if $generate_options in ('wx_gui', 'qt_gui', 'bokeh_gui' )
42
42
if __name__ == '__main__':
43
43
import ctypes
44
44
import sys
@@ -119,6 +119,15 @@ class $(class_name)(gr.top_block, Qt.QWidget):
119
119
120
120
self.settings = Qt.QSettings("GNU Radio", "$class_name")
121
121
self.restoreGeometry(self.settings.value("geometry").toByteArray())
122
+
123
+ #elif $generate_options == 'bokeh_gui'
124
+
125
+ class $(class_name)(gr.top_block):
126
+ def __init__(self, doc):
127
+ gr.top_block.__init__(self, "$title")
128
+ self.doc = doc
129
+ self.plot_lst = []
130
+ self.widget_lst = []
122
131
#elif $generate_options == 'no_gui'
123
132
124
133
@@ -237,6 +246,22 @@ gr.io_signaturev($(len($io_sigs)), $(len($io_sigs)), [$(', '.join($size_strs))])
237
246
#end if
238
247
#end if
239
248
#end for
249
+
250
+ ##########################################################
251
+ ## Create a layout entry if not manually done for BokehGUI
252
+ ##########################################################
253
+ #if $generate_options == 'bokeh_gui'
254
+ if self.widget_lst:
255
+ input_t = bokehgui.BokehLayout.widgetbox(self.widget_lst)
256
+ widgetbox = bokehgui.BokehLayout.WidgetLayout(input_t)
257
+ widgetbox.set_layout(*($flow_graph.get_option('placement')))
258
+ list_obj = [widgetbox] + self.plot_lst
259
+ else:
260
+ list_obj = self.plot_lst
261
+ layout_t = bokehgui.BokehLayout.create_layout(list_obj, "$flow_graph.get_option('sizing_mode')")
262
+ self.doc.add_root(layout_t)
263
+ #end if
264
+
240
265
########################################################
241
266
##Create Connections
242
267
## The port name should be the id of the parent block.
@@ -378,6 +403,37 @@ def main(top_block_cls=$(class_name), options=None):
378
403
#end for
379
404
tb.Wait()
380
405
#end if
406
+ #elif $generate_options == 'bokeh_gui'
407
+ serverProc, port = bokehgui.utils.create_server()
408
+ def killProc(signum, frame, tb):
409
+ tb.stop()
410
+ tb.wait()
411
+ serverProc.terminate()
412
+ serverProc.kill()
413
+ time.sleep(1)
414
+ try:
415
+ \# Define the document instance
416
+ doc = curdoc()
417
+ #if $flow_graph.get_option('author')
418
+ doc.title = "$title - $flow_graph.get_option('author')"
419
+ #else
420
+ doc.title = "$title"
421
+ #end if
422
+ session = push_session(doc, session_id="$flow_graph.get_option('id')",
423
+ url = "http://localhost:" + port + "/bokehgui")
424
+ \# Create Top Block instance
425
+ tb = top_block_cls(doc)
426
+ try:
427
+ tb.start()
428
+ signal.signal(signal.SIGTERM, functools.partial(killProc, tb=tb))
429
+ session.loop_until_closed()
430
+ finally:
431
+ print "Exiting the simulation. Stopping Bokeh Server"
432
+ tb.stop()
433
+ tb.wait()
434
+ finally:
435
+ serverProc.terminate()
436
+ serverProc.kill()
381
437
#elif $generate_options == 'qt_gui'
382
438
from distutils.version import StrictVersion
383
439
if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.0"):
0 commit comments