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": "6d240d4c-18b2-43a2-b488-42aebbe19bb9",
      "label": "Button",
      "name": null,
      "tags": [],
      "type": "default"
    },
    "id": "6d240d4c-18b2-43a2-b488-42aebbe19bb9",
    "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": "89043d6b-f459-4fd3-a2d2-45d4f38af0c3",
      "label": "Button",
      "name": null,
      "tags": [],
      "type": "default"
    },
    "id": "89043d6b-f459-4fd3-a2d2-45d4f38af0c3",
    "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
action

property type: String

A private property used to trigger on_click event handler.

default_action

property type: String

The default action, 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 action name. Use None as a menu separator.

[
  {
    "attributes": {
      "action": null,
      "callback": null,
      "default_action": null,
      "disabled": false,
      "doc": null,
      "icon": null,
      "id": "ce985a1f-400b-4f89-aef5-fba8119ee7b2",
      "label": "Button",
      "menu": [],
      "name": null,
      "tags": [],
      "type": "default"
    },
    "id": "ce985a1f-400b-4f89-aef5-fba8119ee7b2",
    "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": "01ced4c0-9361-48bb-9faa-c59e78dd657e",
      "label": "Button",
      "name": null,
      "tags": [],
      "type": "default"
    },
    "id": "01ced4c0-9361-48bb-9faa-c59e78dd657e",
    "type": "Toggle"
  }
]