jeudi 21 mai 2020

Holoviz Panel: Not able to embed CheckBoxGroup

I can't get the Holoviz Panel ChechBoxGroup Widget to work when it is embedded. I can select the options but the output is not updated. However, if using the RadioBoxGroup with my code it all works as intended. However I need that feature to select multiple things.

In a Jupyter Notebook I have the following code:

import panel as pn
pn.extension()

CheckBoxes = pn.widgets.CheckBoxGroup(value=['1'], options=['1','2','3','4'])

@pn.depends(CheckBoxes.param.value)
def callback(value):
    sum = 0
    for i in range(len(value)):
        sum = sum + int(value[i])
    return sum

row = pn.Row(CheckBoxes, callback)
row.embed()

Changing it up a bit to use the RadioBoxGroup

import panel as pn
pn.extension()

CheckBoxes = pn.widgets.RadioBoxGroup(value=['1'], options=['1','2','3','4'])

@pn.depends(CheckBoxes.param.value)
def callback(value):
    return value

row = pn.Row(CheckBoxes, callback)
row.embed()

And everything works as intended. Thanks in advance!




Aucun commentaire:

Enregistrer un commentaire