I’ve run the examples/glyphs/buttons_server.py example and it works fine using the following process
start “bokeh serve” in one terminal window
execute “python buttons_server.py” in another terminal window
then a browser window starts up with all of the defined buttons
button actions print to the 2nd terminal window as expected given the print statements in the callback functions
Here is my question: I would like to use a toggle button such that when active = True the button text is “Start” and the button color is green and when active = False the button text is “Stop” and the button color is red. I’ve been through the documentation and docstring (i.e., help(bokeh.models.widgets.Toggle)), but haven’t been able to figure out how to do this. Any suggestions on where I ought to look next?
I've run the examples/glyphs/buttons_server.py example and it works fine using the following process
1. start "bokeh serve" in one terminal window
2. execute "python buttons_server.py" in another terminal window
3. then a browser window starts up with all of the defined buttons
4. button actions print to the 2nd terminal window as expected given the print statements in the callback functions
Here is my question: I would like to use a toggle button such that when active = True the button text is "Start" and the button color is green and when active = False the button text is "Stop" and the button color is red. I've been through the documentation and docstring (i.e., help(bokeh.models.widgets.Toggle)), but haven't been able to figure out how to do this. Any suggestions on where I ought to look next?
I whittled down buttons_server.py to the code below (toggle.py) and change the label property in the callback. When I run “bokeh serve” and “python toggle.py” I see a button in a browser window labeled “Toggle Button”. Here is what I see after each subsequent click of the button:
no change in text
“start”
no change in text
“stop”
“start”
no change in text
“stop”
“start”
no change in text
I’m apparently missing something here. Any suggestions?
I’ve run the examples/glyphs/buttons_server.py example and it works fine using the following process
start “bokeh serve” in one terminal window
execute “python buttons_server.py” in another terminal window
then a browser window starts up with all of the defined buttons
button actions print to the 2nd terminal window as expected given the print statements in the callback functions
Here is my question: I would like to use a toggle button such that when active = True the button text is “Start” and the button color is green and when active = False the button text is “Stop” and the button color is red. I’ve been through the documentation and docstring (i.e., help(bokeh.models.widgets.Toggle)), but haven’t been able to figure out how to do this. Any suggestions on where I ought to look next?
Thanks,
Greg
–
You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
Not missing anything, the toggle implementation was just not very reliable, it was trying to to set the active state based on the presence or absence of the CSS class. It works much better to explicitly maintain the state and set the class based on that:
Thanks for the help! The PR is submitted. Hopefully it can make it into the next dev release. I checked button.coffee and it just increments a counter. I also looked at radio_button_group.coffee and it looks a little suspect to me, but I don’t know enough about coffeescript (or javascript) to really know.
Greg
···
On Friday, December 25, 2015 at 4:14:13 PM UTC-7, Bryan Van de ven wrote:
Greg,
Not missing anything, the toggle implementation was just not very reliable, it was trying to to set the active state based on the presence or absence of the CSS class. It works much better to explicitly maintain the state and set the class based on that: