0

I am trying to create an interactive IntSlider widget, which calls another function when it updates. The function is callback(parameter) - the parameter inside is a rating.

The callback(rating) function's purpose is that it updates the visible businesses on the map according to their RatingValue.

So far my code looks like this:

def set_interactive():    
# YOUR CODE HERE

def f(x):
    return x = callback(RatingValue)

return interact(f, x=widgets.IntSlider(min=0,max=5,step=1,value=0));

When running this code, I get this error: return x = callback('RatingValue') ^ SyntaxError: invalid syntax

Sometimes I also get this error: AttributeError: module 'bokeh.models.widgets' has no attribute 'IntSlider'

even though I have imported the IntSlider from the ipywidgets module.

4

1 回答 1

0

You are mixing up two different libraries. Bokeh widgets and ipywidgets are different things, In your code above, widgets is evidently the bokeh.widgets module (which does not have an IntSlider as the exception states). If there is an IntSlider in ipywidgets that you have imported, presumably you need to pass that:

return interact(f, x=IntSlider(min=0,max=5,step=1,value=0))  # no "widgets."
于 2019-05-25T17:35:02.887 回答