Widget - Buttons - Active/Inactive color/Alpha

Hello All,

is there any way how to determine user color of a “button” or “CheckboxButtonGroup” when activated / inactivated (also Alpha)?

  • Addtional queston how to determine the same behavior of button in example to the “CheckboxButtonGroup” if I would have same amount of Groupded Buttons? Concretally Im asking about visible parameter of chart Glymphs like (toggle2.js_link('active', pink_line, 'visible'))

Button Examples:

from bokeh.layouts import layout
from bokeh.models import BoxAnnotation, Toggle
from bokeh.plotting import figure, show


p = figure(width=600, height=200, tools='')
blue_line = p.line([1, 2, 3], [1, 2, 1], line_color="#0072B2", visible=True)
blue_circles = p.circle([1, 2, 3], [1, 2, 1], color="#0072B2", visible=True)
pink_line = p.line([1, 2, 3], [2, 1, 2], line_color="#CC79A7", visible=False)

green_box = BoxAnnotation(left=1.5, right=2.5, fill_color='#009E73', fill_alpha=0.1, visible=False)
p.add_layout(green_box)

# Use js_link to connect button active property to glyph visible property
toggle_all = Toggle(label="All", button_type="success", active=False)
toggle_all.js_link('active', green_box, 'visible')
toggle_all.js_link('active', blue_line, 'visible')
toggle_all.js_link('active', pink_line, 'visible')
toggle_all.js_link('active', blue_circles, 'visible')

toggle1 = Toggle(label="Blue", button_type="success", active=True)
toggle1.js_link('active', blue_line, 'visible')
toggle1.js_link('active', blue_circles, 'visible')

toggle2 = Toggle(label="Pink Line", button_type="success", active=False)
toggle2.js_link('active', pink_line, 'visible')

toggle3 = Toggle(label="Green background", button_type="success", active=False)
toggle3.js_link('active', green_box, 'visible')

show(layout([p], [toggle1, toggle2, toggle3, toggle_all]))

thank you

Jan

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.