bokeh.models.widgets.buttons

Various kinds of button widgets.

class AbstractButton(**kwargs)

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: 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.

JSON Prototype
{
  "button_type": "default",
  "callback": null,
  "disabled": false,
  "height": null,
  "icon": null,
  "id": "45e47040-f5f5-42a8-9838-49a7f0983829",
  "label": "Button",
  "name": null,
  "sizing_mode": "fixed",
  "tags": [],
  "width": null
}
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
{
  "button_type": "default",
  "callback": null,
  "clicks": 0,
  "disabled": false,
  "height": null,
  "icon": null,
  "id": "2aec57da-2452-44c7-800d-7e1df39a8694",
  "label": "Button",
  "name": null,
  "sizing_mode": "fixed",
  "tags": [],
  "width": null
}
class ButtonLike(**properties)

Shared properties for button-like widgets.

button_type

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

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

type
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
{
  "button_type": "default",
  "callback": null,
  "default_value": null,
  "disabled": false,
  "height": null,
  "icon": null,
  "id": "934a1f5d-2ec0-43e4-9104-1ac6383bc3b3",
  "label": "Dropdown",
  "menu": [],
  "name": null,
  "sizing_mode": "fixed",
  "tags": [],
  "value": null,
  "width": 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,
  "button_type": "default",
  "callback": null,
  "disabled": false,
  "height": null,
  "icon": null,
  "id": "2afebe26-f21e-4e34-966b-2ffa47200752",
  "label": "Toggle",
  "name": null,
  "sizing_mode": "fixed",
  "tags": [],
  "width": null
}