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. AbstractButton is not generally 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
{
  "button_type": "default",
  "callback": null,
  "css_classes": null,
  "disabled": false,
  "height": null,
  "icon": null,
  "id": "9a1e463f-491b-4044-bbd7-465a7dc2bcdb",
  "js_callbacks": {},
  "label": "Button",
  "name": null,
  "sizing_mode": "fixed",
  "tags": [],
  "width": null
}
class Button(**kwargs)[source]

Bases: bokeh.models.widgets.buttons.AbstractButton

A click button.

clicks

property type: Int

A private property used to trigger on_click event handler.

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
{
  "button_type": "default",
  "callback": null,
  "clicks": 0,
  "css_classes": null,
  "disabled": false,
  "height": null,
  "icon": null,
  "id": "f7f59101-907e-4285-af4f-e8a40d6d76c0",
  "js_callbacks": {},
  "label": "Button",
  "name": null,
  "sizing_mode": "fixed",
  "tags": [],
  "width": null
}
class ButtonLike(**properties)[source]

Shared properties for button-like widgets.

button_type

property type: Enum ( ButtonType )

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

type
class Dropdown(**kwargs)[source]

Bases: bokeh.models.widgets.buttons.AbstractButton

A dropdown button.

default_value

property type: String

The default value, otherwise the first item in menu will be used.

menu

property type: List ( Tuple ( String , String ) )

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

value

property type: String

A private property used to trigger on_click event handler.

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
{
  "button_type": "default",
  "callback": null,
  "css_classes": null,
  "default_value": null,
  "disabled": false,
  "height": null,
  "icon": null,
  "id": "68096891-c1e9-4a00-b27e-435d0c9057f3",
  "js_callbacks": {},
  "label": "Dropdown",
  "menu": [],
  "name": null,
  "sizing_mode": "fixed",
  "tags": [],
  "value": null,
  "width": null
}
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.

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,
  "button_type": "default",
  "callback": null,
  "css_classes": null,
  "disabled": false,
  "height": null,
  "icon": null,
  "id": "a1706d29-83e9-4cb9-af77-1c558374635b",
  "js_callbacks": {},
  "label": "Toggle",
  "name": null,
  "sizing_mode": "fixed",
  "tags": [],
  "width": null
}