☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

Select widget

Community Support
shakeel
shakeel

Hi I am working on select widget of Bokeh

I have a dataframe with following

df.columns=si,se,cel

si =[A,B,A,B,A,B]
se=[A_1,A_2,A_3,B_1,B_2,B_3,A_1,A_2,A_3,B_1,B_2,B_3]
cel=[AA_1,AA_2,AA_3,AA_4,AA_5,AA_6,BB_1,BB_2,BB_3,BB_4,BB_5,BB_6,AA_1,AA_2,AA_3,AA_4,AA_5,AA_6,BB_1,BB_2,BB_3,BB_4,BB_5,BB_6]

My task is to create 3 SELECT WIDGET

WHEN i chose A

si =[A]
se=[A_1,A_2,A_3]
ce=[AA_1,AA_2,AA_3,AA_4,AA_5,AA_6]

after that

si =[A]
se=[A_1]
ce=[AA_1,AA_4]

and so on
I have to chose from se widget

i am able to create
WHEN i chose A

si =[A]
se=[A_1,A_2,A_3]

but unable to do the rest of the part

following is call back code

def update_plot(attr, old, new):
    # If select1 is 'A' 
    if select1.value == df_lrd[0]:
        df_new=df[df['lrd_4']==df_lrd[0]]
        # Set select2 options to ['1', '2', '3']
        df_s=df_new['sec'].unique().tolist()
        select2.options =df_s
        df_n_c=[]
        for s in range(len(df_s)):
            select2.value=df_s[s]
            df_n_s=df[df['sec']==df_s[s]]
            # df_n_c=df_n_s['cell_name_new'].unique().tolist()
            df_n_c.append(list(df_n_s['cell_name_new'].unique()))
            select3.options =df_n_c
    else:
        select1.value == df_lrd[1]
        df_new=df[df['lrd_4']==df_lrd[1]]
        df_s=df_new['sec'].unique().tolist()
        select2.options =df_s
        df_n_c=[]
        for s in range(len(df_s)):
            select2.value=df_s[s]
            df_n_s=df[df['sec']==df_s[s]]
            # df_n_c=df_n_s['cell_name_new'].unique().tolist()
            df_n_c.append(list(df_n_s['cell_name_new'].unique()))
            select3.options =df_n_c

# Attach the update_plot callback to the 'value' property of select
select1.on_change('value', update_plot)
select2.on_change('value', update_plot)
select3.on_change('value', update_plot)

layout = widgetbox(select1,select2,select3, p)
curdoc().add_root(layout)
⌁   Link to post
Bryan
Bryan

It seems to me that you will need more that one callback. When the first slider updates, you need to both he second and third widgets need updating. When the second slider updates, you only need to update the third. A single plain callback does not know which widget triggered it, so that will not be sufficient. I would suggest you take a step back and try to get things working on a toy version with much less logic and code.

⌁   Link to post

End of archived discussion · Replies are disabled