Change the RadioButtonGroup values based on Select widget

Hello,

Is it possible to change the RadioButtonGroup values based on Select widget in Bokeh?

Thanks

Pratik

Yes, you can do this by assigning a new value to the attribute you wish to change within a callback. Using bokeh server, one such callback could look like this:

def myCallback(attr, old, new):
    myRbgWidget.labels = newLabels
mySelectWidget.on_change('value', myCallback)

Using a javascript callback it might look like this:

cb = CustomJS(args=dict(myRgbWidget=myRgbWidget, newLabels=newLabels), code=    '''
myRgbWidget.labels = newLabels;
'''
)
mySelectWidget.js_on_change('value', cb)

If you aren’t familiar with callbacks, the tutorial notebooks on Bokeh Apps and Adding Interactions should help you put these snippets in context.

···

On Thu, Feb 2, 2017 at 5:10 AM, [email protected] wrote:

Hello,

Is it possible to change the RadioButtonGroup values based on Select widget in Bokeh?

Thanks

Pratik

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

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/08cb5629-4aea-4f0a-9b01-312cc28b1361%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi Tyler,

Do you mind providing a small example of it?

Thank you,

Pratik

···

On Thursday, 2 February 2017 16:29:38 UTC-5, Tyler Nickerson wrote:

Yes, you can do this by assigning a new value to the attribute you wish to change within a callback. Using bokeh server, one such callback could look like this:

def myCallback(attr, old, new):
    myRbgWidget.labels = newLabels
mySelectWidget.on_change('value', myCallback)

Using a javascript callback it might look like this:

cb = CustomJS(args=dict(myRgbWidget=myRgbWidget, newLabels=newLabels), code=    '''
myRgbWidget.labels = newLabels;
'''
)
mySelectWidget.js_on_change('value', cb)

If you aren’t familiar with callbacks, the tutorial notebooks on Bokeh Apps and Adding Interactions should help you put these snippets in context.

On Thu, Feb 2, 2017 at 5:10 AM, [email protected] wrote:

Hello,

Is it possible to change the RadioButtonGroup values based on Select widget in Bokeh?

Thanks

Pratik

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

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/08cb5629-4aea-4f0a-9b01-312cc28b1361%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

No problem, here’s a working example using Bokeh Server

from [bokeh.io](http://bokeh.io) import curdoc
from bokeh.layouts import row
from bokeh.models.widgets import Select, RadioButtonGroup
select = Select(options=['foo', 'bar'], value='foo'
)
newLabels = {
'foo': ['foobar', 'foobaz'    ],
'bar': ['barfoo', 'barbaz'
]
}
radio = RadioButtonGroup(labels=newLabels['foo'
])
layout = row(select, radio)
def callback(attr, old, new):
    radio.labels = newLabels[select.value]
select.on_change('value'
, callback)
curdoc().add_root(layout)

···

On Thu, Feb 2, 2017 at 4:45 PM, [email protected] wrote:

Hi Tyler,

Do you mind providing a small example of it?

Thank you,

Pratik

On Thursday, 2 February 2017 16:29:38 UTC-5, Tyler Nickerson wrote:

Yes, you can do this by assigning a new value to the attribute you wish to change within a callback. Using bokeh server, one such callback could look like this:

def myCallback(attr, old, new):
    myRbgWidget.labels = newLabels
mySelectWidget.on_change('value', myCallback)

Using a javascript callback it might look like this:

cb = CustomJS(args=dict(myRgbWidget=myRgbWidget, newLabels=newLabels), code=    '''
myRgbWidget.labels = newLabels;
'''
)
mySelectWidget.js_on_change('value', cb)

If you aren’t familiar with callbacks, the tutorial notebooks on Bokeh Apps and Adding Interactions should help you put these snippets in context.

On Thu, Feb 2, 2017 at 5:10 AM, [email protected] wrote:

Hello,

Is it possible to change the RadioButtonGroup values based on Select widget in Bokeh?

Thanks

Pratik

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

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/08cb5629-4aea-4f0a-9b01-312cc28b1361%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

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

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/5c99b6a9-fa43-4bee-ba4d-3d9146183771%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Thank you so much Tyler. Really appreciate your help!

···

On Thursday, 2 February 2017 20:34:34 UTC-5, Tyler Nickerson wrote:

No problem, here’s a working example using Bokeh Server

from [bokeh.io](http://bokeh.io) import curdoc
from bokeh.layouts import row
from bokeh.models.widgets import Select, RadioButtonGroup
select = Select(options=['foo', 'bar'], value='foo'
)
newLabels = {
'foo': ['foobar', 'foobaz'    ],
'bar': ['barfoo', 'barbaz'
]
}
radio = RadioButtonGroup(labels=newLabels['foo'
])
layout = row(select, radio)
def callback(attr, old, new):
    radio.labels = newLabels[select.value]
select.on_change('value'
, callback)
curdoc().add_root(layout)

On Thu, Feb 2, 2017 at 4:45 PM, [email protected] wrote:

Hi Tyler,

Do you mind providing a small example of it?

Thank you,

Pratik

On Thursday, 2 February 2017 16:29:38 UTC-5, Tyler Nickerson wrote:

Yes, you can do this by assigning a new value to the attribute you wish to change within a callback. Using bokeh server, one such callback could look like this:

def myCallback(attr, old, new):
    myRbgWidget.labels = newLabels
mySelectWidget.on_change('value', myCallback)

Using a javascript callback it might look like this:

cb = CustomJS(args=dict(myRgbWidget=myRgbWidget, newLabels=newLabels), code=    '''
myRgbWidget.labels = newLabels;
'''
)
mySelectWidget.js_on_change('value', cb)

If you aren’t familiar with callbacks, the tutorial notebooks on Bokeh Apps and Adding Interactions should help you put these snippets in context.

On Thu, Feb 2, 2017 at 5:10 AM, [email protected] wrote:

Hello,

Is it possible to change the RadioButtonGroup values based on Select widget in Bokeh?

Thanks

Pratik

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

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/08cb5629-4aea-4f0a-9b01-312cc28b1361%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

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

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/5c99b6a9-fa43-4bee-ba4d-3d9146183771%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.