ValueError when writing new options to Select widget

import panel as pn



def callback_(*events):
    global UPDATING
    if UPDATING:


    UPDATING = True

    for event in events:
        if == 'value':
            res = [int(i) for i in event.obj.options[1:]]
            res = ['----'] + [str(i + 1) for i in res]
            event.obj.options = res

    UPDATING = False

toggle = pn.widgets.Select(name='Select', options=['----', '1', '2', '3', '4'])

dashboard = pn.Row(

watcher =, ['value'])


If I select 1 in the options, I get a ValueError exception ValueError: 1 not in list

Which version of Panel are you using? Can’t reproduce.

I am using 1.3.8 version in Jupyter notebook

This ValueError only occurs if I select the first value after ‘----’. At beginning if I select 1, the new list changes to [‘----’, ‘2’, ‘3’, ‘4’, ‘5’] and ‘1’ is no longer in it.

It seems like if I serve it in a browser, the exception is gone. However, this does effect the Jupyter version.

This is also related to one of my previous questions SOLVED: Updating Select widget options on new value gives ValueError - #3 by lyubomyrk, where I did find I needed a better solution haha and this is what I have figured out. You pointed me to the param class and that was the solution. I only care about the browser version so this works.

I think you might want to use select.objects = pn.bind(callable, select.param.value) over

More resources: