bokeh.models.widgets.buttons

Various kinds of button widgets.

class AbstractButton(**kwargs)[source]

Bases: bokeh.models.widgets.widget.Widget, bokeh.models.widgets.buttons.ButtonLike

A base class that defines common properties for all button types.

Note

This is an abstract base class used to help organize the hierarchy of Bokeh model types. It is not useful to instantiate on its own.

callback

property type: Instance ( Callback )

A callback to run in the browser whenever the button is activated.

icon

property type: Instance ( AbstractIcon )

An optional image appearing to the left of button’s text.

label

property type: String

The text label for the button to display.

JSON Prototype
{
  "align": "start",
  "aspect_ratio": null,
  "background": null,
  "button_type": "default",
  "callback": null,
  "css_classes": [],
  "default_size": 300,
  "disabled": false,
  "height": null,
  "height_policy": "auto",
  "icon": null,
  "id": "14427",
  "js_event_callbacks": {},
  "js_property_callbacks": {},
  "label": "",
  "margin": [
    5,
    5,
    5,
    5
  ],
  "max_height": null,
  "max_width": null,
  "min_height": null,
  "min_width": null,
  "name": null,
  "orientation": "horizontal",
  "sizing_mode": null,
  "subscribed_events": [],
  "tags": [],
  "visible": true,
  "width": null,
  "width_policy": "auto"
}
class Button(**kwargs)[source]

Bases: bokeh.models.widgets.buttons.AbstractButton

A click button.

clicks

property type: Int

A private property that used to trigger on_click event handler.

js_on_click(handler)[source]

Set up a JavaScript handler for button clicks.

on_click(handler)[source]

Set up a handler for button clicks.

Parameters

handler (func) – handler function to call when button is clicked.

Returns

None

JSON Prototype
{
  "align": "start",
  "aspect_ratio": null,
  "background": null,
  "button_type": "default",
  "callback": null,
  "clicks": 0,
  "css_classes": [],
  "default_size": 300,
  "disabled": false,
  "height": null,
  "height_policy": "auto",
  "icon": null,
  "id": "14431",
  "js_event_callbacks": {},
  "js_property_callbacks": {},
  "label": "Button",
  "margin": [
    5,
    5,
    5,
    5
  ],
  "max_height": null,
  "max_width": null,
  "min_height": null,
  "min_width": null,
  "name": null,
  "orientation": "horizontal",
  "sizing_mode": null,
  "subscribed_events": [],
  "tags": [],
  "visible": true,
  "width": null,
  "width_policy": "auto"
}
class ButtonLike(**properties)[source]

Shared properties for button-like widgets.

Note

This is an abstract base class used to help organize the hierarchy of Bokeh model types. It is not useful to instantiate on its own.

button_type

property type: Enum ( ButtonType )

A style for the button, signifying it’s role.

class Dropdown(**kwargs)[source]

Bases: bokeh.models.widgets.buttons.AbstractButton

A dropdown button.

default_value

property type: String

A default value to set when a split Dropdown’s top button is clicked.

Setting this property will cause the Dropdown to be rendered as split.

menu

property type: List ( Either ( String , Tuple ( String , Either ( String , Instance ( Callback ) ) ) ) )

Button’s dropdown menu consisting of entries containing item’s text and value name. Use None as a menu separator.

split

property type: Bool

value

property type: String

A private property that used to trigger on_click event handler.

js_on_click(handler)[source]

Set up a JavaScript handler for button or menu item clicks.

on_click(handler)[source]

Set up a handler for button or menu item clicks.

Parameters

handler (func) – handler function to call when button is activated.

Returns

None

JSON Prototype
{
  "align": "start",
  "aspect_ratio": null,
  "background": null,
  "button_type": "default",
  "callback": null,
  "css_classes": [],
  "default_size": 300,
  "default_value": null,
  "disabled": false,
  "height": null,
  "height_policy": "auto",
  "icon": null,
  "id": "14433",
  "js_event_callbacks": {},
  "js_property_callbacks": {},
  "label": "Dropdown",
  "margin": [
    5,
    5,
    5,
    5
  ],
  "max_height": null,
  "max_width": null,
  "menu": [],
  "min_height": null,
  "min_width": null,
  "name": null,
  "orientation": "horizontal",
  "sizing_mode": null,
  "split": false,
  "subscribed_events": [],
  "tags": [],
  "value": null,
  "visible": true,
  "width": null,
  "width_policy": "auto"
}
class Toggle(**kwargs)[source]

Bases: bokeh.models.widgets.buttons.AbstractButton

A two-state toggle button.

active

property type: Bool

The initial state of a button. Also used to trigger on_click event handler.

js_on_click(handler)[source]

Set up a JavaScript handler for button state changes (clicks).

on_click(handler)[source]

Set up a handler for button state changes (clicks).

Parameters

handler (func) – handler function to call when button is toggled.

Returns

None

JSON Prototype
{
  "active": false,
  "align": "start",
  "aspect_ratio": null,
  "background": null,
  "button_type": "default",
  "callback": null,
  "css_classes": [],
  "default_size": 300,
  "disabled": false,
  "height": null,
  "height_policy": "auto",
  "icon": null,
  "id": "14438",
  "js_event_callbacks": {},
  "js_property_callbacks": {},
  "label": "Toggle",
  "margin": [
    5,
    5,
    5,
    5
  ],
  "max_height": null,
  "max_width": null,
  "min_height": null,
  "min_width": null,
  "name": null,
  "orientation": "horizontal",
  "sizing_mode": null,
  "subscribed_events": [],
  "tags": [],
  "visible": true,
  "width": null,
  "width_policy": "auto"
}