Bokeh web app not showing in browser

Hi,
I’m new to Bokeh and just trying things out. I’ve tried to create a simple web app which generates a sine wave with a random frequency from a button press. I’ve created a class which inherits from VBox and stores a button and plot in the children. When I run the app with ‘bokeh serve --show MyApp.py’ at the command prompt, the server starts and I get no errors, but the browser window is empty. Don’t know what I’m doing wrong but any help gratefully received!
Thanks,
Marcus.
Code…

import numpy

from bokeh.models import Button, Plot, ColumnDataSource
from bokeh.plotting import Figure, curdoc
from bokeh.models.widgets.layouts import VBox

from bokeh.core.properties import Instance,Float
from bokeh.models.sources import DataSource

class 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())

Before anyone points it out I know the second last line should be:
self.ds.data[‘y’] = numpy.sin(2numpy.piself.f*self.ds.data[‘x’])
and the x range should be 0 to 1.
… doh!

Obviously that hasn’t solved the problem though.

Forgot to mention, I’m using Bokeh version 0.11.0, running on Ubuntu 14.04 with Firefox as the browser.

Marcus.

···

On Monday, January 11, 2016 at 1:50:28 PM UTC, Marcus Donnelly wrote:

Hi,
I’m new to Bokeh and just trying things out. I’ve tried to create a simple web app which generates a sine wave with a random frequency from a button press. I’ve created a class which inherits from VBox and stores a button and plot in the children. When I run the app with ‘bokeh serve --show MyApp.py’ at the command prompt, the server starts and I get no errors, but the browser window is empty. Don’t know what I’m doing wrong but any help gratefully received!
Thanks,
Marcus.
Code…

import numpy

from bokeh.models import Button, Plot, ColumnDataSource
from bokeh.plotting import Figure, curdoc
from bokeh.models.widgets.layouts import VBox

from bokeh.core.properties import Instance,Float
from bokeh.models.sources import DataSource

class 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())