gradio-app / gradio

Build and share delightful machine learning apps, all in Python. 🌟 Star to support our work!
http://www.gradio.app
Apache License 2.0
33.41k stars 2.53k forks source link

A button component cannot be displayed within a Dataframe. #6621

Closed Zilong01 closed 10 months ago

Zilong01 commented 10 months ago

Describe the bug

I want to build a table now, where there are several buttons in the last few columns. When the button is pressed, it will trigger the corresponding operation (based on the information of the current row). I tried to put gr. Button in the input of the data frame, but the only text displayed on the interface was the 'Button' text, not a button that could be pressed. How can I place a button on each row of a table?

Have you searched existing issues? πŸ”Ž

Reproduction

record_dataframe = gr.DataFrame(
            label="record", 
            headers=["a", "b", "c", "d", "e", "f"],
            column_widths=["12%", "20%", "20%", "8%", "30%", "10%"])

# select data in database , and return a list. 
def select_fankui(userid):

    records = db_select_fankui_record(userid)

    records, question_content_list = fankuiresult_btn(records) # This function turns the last element of the list into a Gr.Button

    return records, gr.Dropdown(choices=question_content_list, visible=True)

select_fankui_btn.click(fn=select_fankui, inputs=[sender], outputs=[record_dataframe, fankui_id_dropdown]) # put data into dataframe

Screenshot

bug1

Logs

No response

System Info

gradio==4.7.1

Severity

Blocking usage of gradio

MiirzaBaig commented 10 months ago

Could you assign me ?

abidlabs commented 10 months ago

Hi @Zilong01 this is not something that is supported. It is probably out of scope of a regular gr.Dataframe, but it could be an interesting custom component, as mentioned here: https://github.com/gradio-app/gradio/issues/2006