Greetings:
I have created a script that allows me to automatically launch a browser and stream data using the following abbreviated code:
import modules
io_loop = IOLoop.current()
def build_doc(doc):
Build widgets
l = layout([widgetbox1],[widgetbox[2],[widgetbox[3])
@count()
def update_Data(ct):
def BuildCallBack(att,old,new)
doc.add_root(l)
doc.add_periodic_callback(update_Data, 500) #update data ever 500 ms
bokeh_app = Application(FunctionHandler(build_doc))
url = “http://localhost:5006/”
browser = webbrowser.get() #get the default webbrowser
browser.open(url,2)
server = Server({’/’: bokeh_app}, io_loop=io_loop)
server.start()
if name == ‘ALDGUI’:
print(‘Opening Bokeh application on http://localhost:5006/’)
io_loop.add_callback(server.show, “/”)
io_loop.start()
print("\npress ctrl-C to exit")
io_loop_until_closed()
This works perfectly…
I have now converted this script to a class object such as:
class ALDWeb:
def init(self):
self.io_loop = IOLoop.current()
self.SetLayout()
def SetLayout(self):
def WidgetHandlers(self,attr,old_value, new_value):
if name == ‘main’:
test = ALDWeb()
My question is how do I go about passing my doc variable to my class, such that i can now add the below line of code to automatically start my bokeh serve?
doc.add_root(ALDWeb())
doc.add_periodic_callback(update_Data, 500) #update data ever 500 ms
bokeh_app = Application(FunctionHandler(build_doc))
url = “http://localhost:5006/”
browser = webbrowser.get() #get the default webbrowser
browser.open(url,2)
server = Server({’/’: bokeh_app}, io_loop=io_loop)
server.start()
if name == ‘ALDGUI’:
print(‘Opening Bokeh application on http://localhost:5006/’)
io_loop.add_callback(server.show, “/”)
io_loop.start()
print("\npress ctrl-C to exit")
io_loop_until_closed()
Thanks.
V