bokeh.models.widgets.buttons

Various kinds of button widgets.

class AbstractButton(**kwargs)

Bases: bokeh.models.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: 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.

type

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

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

[
  {
    "attributes": {
      "callback": null,
      "disabled": false,
      "doc": null,
      "icon": null,
      "id": "f19170d3-7fa3-4f4e-a544-e0557924a07e",
      "label": "Button",
      "name": null,
      "tags": [],
      "type": "default"
    },
    "id": "f19170d3-7fa3-4f4e-a544-e0557924a07e",
    "type": "AbstractButton"
  }
]
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: Int

A private property used to trigger on_click event handler.

[
  {
    "attributes": {
      "callback": null,
      "clicks": 0,
      "disabled": false,
      "doc": null,
      "icon": null,
      "id": "bf80d9ff-e723-44a9-80d7-2fb3e3674270",
      "label": "Button",
      "name": null,
      "tags": [],
      "type": "default"
    },
    "id": "bf80d9ff-e723-44a9-80d7-2fb3e3674270",
    "type": "Button"
  }
]
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: 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.

[
  {
    "attributes": {
      "callback": null,
      "default_value": null,
      "disabled": false,
      "doc": null,
      "icon": null,
      "id": "b8f48619-9d7a-4f5d-91fe-23b53a6389e5",
      "label": "Button",
      "menu": [],
      "name": null,
      "tags": [],
      "type": "default",
      "value": null
    },
    "id": "b8f48619-9d7a-4f5d-91fe-23b53a6389e5",
    "type": "Dropdown"
  }
]
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: Bool

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

[
  {
    "attributes": {
      "active": false,
      "callback": null,
      "disabled": false,
      "doc": null,
      "icon": null,
      "id": "9182add5-a83a-40f4-b038-e2824add98d4",
      "label": "Button",
      "name": null,
      "tags": [],
      "type": "default"
    },
    "id": "9182add5-a83a-40f4-b038-e2824add98d4",
    "type": "Toggle"
  }
]