bokeh.models.widgets.buttons

Various kinds of button widgets.

class AbstractButton(**kwargs)

Bases: bokeh.models.widgets.widget.Widget

A base class that defines common properties for all button types. AbstractButton is not generally useful to instantiate on its own.

callback

property type: callback:Instance(Callback)

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

icon

property type: icon:Instance(AbstractIcon)

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

label

property type: label:String

The text label for the button to display.

type

property type: type:Enum(‘default’, ‘primary’, ‘success’, ‘warning’, ‘danger’, ‘link’)

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

JSON Prototype
{
  "callback": null,
  "disabled": false,
  "icon": null,
  "id": "e4b58ea9-c575-4a11-ab36-8ac70732a390",
  "label": "Button",
  "name": null,
  "tags": [],
  "type": "default"
}
class Button(**kwargs)

Bases: bokeh.models.widgets.buttons.AbstractButton

A click button.

on_click(handler)

Set up a handler for button clicks.

Parameters:handler (func) – handler function to call when button is clicked.
Returns:None
clicks

property type: clicks:Int

A private property used to trigger on_click event handler.

JSON Prototype
{
  "callback": null,
  "clicks": 0,
  "disabled": false,
  "icon": null,
  "id": "e9c7c716-afb4-446c-87a4-9994b59289ae",
  "label": "Button",
  "name": null,
  "tags": [],
  "type": "default"
}
class Dropdown(**kwargs)

Bases: bokeh.models.widgets.buttons.AbstractButton

A dropdown button.

on_click(handler)

Set up a handler for button or menu item clicks.

Parameters:handler (func) – handler function to call when button is activated.
Returns:None
default_value

property type: default_value:String

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

menu

property type: menu: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: value:String

A private property used to trigger on_click event handler.

JSON Prototype
{
  "callback": null,
  "default_value": null,
  "disabled": false,
  "icon": null,
  "id": "9d30734f-3868-462e-9ecb-44761bbbefe9",
  "label": "Dropdown",
  "menu": [],
  "name": null,
  "tags": [],
  "type": "default",
  "value": null
}
class Toggle(**kwargs)

Bases: bokeh.models.widgets.buttons.AbstractButton

A two-state toggle button.

on_click(handler)

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

Parameters:handler (func) – handler function to call when button is toggled.
Returns:None
active

property type: active:Bool

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

JSON Prototype
{
  "active": false,
  "callback": null,
  "disabled": false,
  "icon": null,
  "id": "3e604d8a-cc24-49ff-b1f3-bb3d0f9686a1",
  "label": "Toggle",
  "name": null,
  "tags": [],
  "type": "default"
}