wild guess (not at my computer) you may have a JS error about no view for MyApp.
To tell it to use the VBox view adding “view_model = ‘VBox’” might work (something like that anyway)
You could also skip the inheritance and use globals or composition.
Havoc
···
On Jan 11, 2016, at 8:29 AM, [email protected] wrote:
Hi,
I’m trying to inherit from a VBox class to create a simple class which plots sine waves with a random frequency. The code is below. I start the Bokeh server with the command ‘bokeh serve --show MyApp.py’. The browser launches and I get no error messages at the command prompt, but nether the button nor the plot appear. Any help would be much appreciated. I’m new to Bokeh so forgive me if I’m doing something daft!
I’m using Bokeh version 0.11.0, running on Ubuntu 14.04.
Thanks,
Marcus.
Code…import numpy
from bokeh.models import Button, Plot, ColumnDataSource
from bokeh.plotting import Figure, curdoc
from bokeh.models.widgets.layouts import VBoxfrom bokeh.core.properties import Instance,Float
from bokeh.models.sources import DataSourceclass MyApp(VBox):
button = Instance(Button) plot = Instance(Plot) ds = Instance(DataSource) f = Float def __init__(self): super(MyApp,self).__init__() self.button = Button(label="Randomise Frequency") self.button.on_click(self.callback) self.f = 1.0 self.plot = Figure(x_range=[0,2*numpy.pi],y_range=[-1, 1]) self.ds = ColumnDataSource(data={'x':numpy.linspace(0,2*numpy.pi,100),'y':numpy.zeros(100)}) self.plot.line('x','y',source=self.ds,line_width=2,line_alpha=0.5) self.children.append(self.button) self.children.append(self.plot) def callback(self): self.f = numpy.random.rand()*10 self.ds.data['y'] = 2*numpy.pi*self.f*self.ds.data['x']
curdoc().add_root(MyApp())
–
You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/0dec772d-a0e4-4d20-b455-24e9da2b14d5%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.