Python bokeh.models.widgets.Slider() Examples

The following are 3 code examples of bokeh.models.widgets.Slider(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module bokeh.models.widgets , or try the search function .
Example #1
Source File: stock.py    From osqf2015 with MIT License 6 votes vote down vote up
def setup_events(self):
        """Attaches the on_change event to the value property of the widget.

        The callback is set to the input_change method of this app.
        """
        super(StockApp, self).setup_events()

        logging.debug("%s" % str(self.source))
        # Slider event registration
        # self.source.on_change('selected', self, 'on_selection_change')
        print("+++++++++++++++++++++++++++++++++")
        print(self)
        self.stock_plot.on_change('value', self, 'input_change')
        # self.outliers_source.on_change('selected', self, 'on_selection_change')
        # for w in ["bins"]:
        #     getattr(self, w).on_change('value', self, 'input_change') 
Example #2
Source File: liveclient.py    From backtrader_plotting with GNU General Public License v3.0 5 votes vote down vote up
def _get_config_panel(self):
        def on_change_checkbox(vals):
            for i, f in enumerate(self._bokeh.figurepages[0].figure_envs):
                if i > 1:
                    continue
                f.figure.visible = i in vals

        self._slider_aspectratio = Slider(value=self._scheme.plotaspectratio, start=0.1, end=10.0, step=0.1)

        button = Button(label="Save", button_type="success")
        button.on_click(self.on_button_save_config)

        r1 = row(children=[Div(text='Aspect Ratio', margin=(15, 10, 0, 10)), self._slider_aspectratio])

        return Panel(child=column(children=[r1, button]), title='Config') 
Example #3
Source File: bokeh_sliders.py    From signaltrain with GNU General Public License v3.0 4 votes vote down vote up
def update_effect(attrname, old, new):
    global effect, model, knob_names, knob_ranges, num_knobs, knob_sliders
    # match the menu option with the right entry in effects_dict
    long_name = effect_select.value
    plot.title.text = f"Trying to setup effect '{long_name}'..."
    shortname = ''
    for key, val in effects_dict.items():
        if val['name'] == long_name:
            shortname = key
            break
    if '' == shortname:
        plot.title.text = f"**ERROR: Effect '{long_name}' not defined**"
        return
    effect = effects_dict[shortname]['effect']
    num_knobs = 0
    if effect is not None:
        knob_names, knob_ranges = effect.knob_names, np.array(effect.knob_ranges)
        num_knobs = len(knob_names)

    # try to read the checkpoint file
    checkpoint_file = effects_dict[shortname]['checkpoint']
    model = setup_model(checkpoint_file, fatal=False)
    if model is  None:
        msg = f"**ERROR: checkpoint file '{checkpoint_file}' not found**"
        print("\n",msg)
        plot.title.text = msg

    # rebuild the entire display  (because knobs have changed)
    knob_sliders = []
    if num_knobs > 0:
        knobs_wc = knob_ranges.mean(axis=1)
        for k in range(num_knobs):
            start, end = knob_ranges[k][0], knob_ranges[k][1]
            mid = knobs_wc[k]
            step = (end-start)/25
            tmp = Slider(title=knob_names[k], value=mid, start=start, end=end, step=step)
            knob_sliders.append(tmp)
        for w in knob_sliders:  # since we now defined new widgets, we need triggers for them
            w.on_change('value', update_data)

    inputs = column([effect_select, input_select]+knob_sliders )
    curdoc().clear()
    curdoc().add_root(row(inputs, plot, width=800))
    curdoc().title = "SignalTrain Demo"

    update_data(attrname, old, new)