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
30.56k stars 2.27k forks source link

When using two textboxes in same blocks, if the first textbox is set to interactive=false, the second textbox also becomes disabled. #8461

Closed feiyun0112 closed 2 weeks ago

feiyun0112 commented 3 weeks ago

Describe the bug

When using two textboxes in same blocks, if the first textbox is set to interactive=false, the second textbox also becomes disabled.

Have you searched existing issues? 🔎

Reproduction

import gradio as gr

with gr.Blocks() as demo:
    gr.Textbox("test1", interactive= False)
    gr.Textbox("test2", )

if __name__ == "__main__":
    demo.launch()

Screenshot

image

Logs

No response

System Info

Gradio Environment Information:
------------------------------
Operating System: Windows
gradio version: 4.32.1
gradio_client version: 0.17.0

------------------------------------------------
gradio dependencies in your environment:

aiofiles: 23.2.1
altair: 5.3.0
fastapi: 0.111.0
ffmpy: 0.3.2
gradio-client==0.17.0 is not installed.
httpx: 0.27.0
huggingface-hub: 0.23.2
importlib-resources: 6.4.0
jinja2: 3.1.4
markupsafe: 2.1.5
matplotlib: 3.9.0
numpy: 1.26.4
orjson: 3.10.3
packaging: 24.0
pandas: 2.2.2
pillow: 10.3.0
pydantic: 2.7.2
pydub: 0.25.1
python-multipart: 0.0.9
pyyaml: 6.0.1
ruff: 0.4.6
semantic-version: 2.10.0
tomlkit==0.12.0 is not installed.
typer: 0.12.3
typing-extensions: 4.11.0
urllib3: 2.2.1
uvicorn: 0.30.0
authlib; extra == 'oauth' is not installed.
itsdangerous; extra == 'oauth' is not installed.

gradio_client dependencies in your environment:

fsspec: 2024.5.0
httpx: 0.27.0
huggingface-hub: 0.23.2
packaging: 24.0
typing-extensions: 4.11.0
websockets: 11.0.3

Severity

I can work around it

abidlabs commented 2 weeks ago

Hi @feiyun0112 the reason for this is that you are providing a default value for the gr.Textbox(), which automatically causes it to be non-interactive. You can see this happens even neither of the gr.Textbox have interactive=False:

import gradio as gr

with gr.Blocks() as demo:
    gr.Textbox("test1")
    gr.Textbox("test2")

if __name__ == "__main__":
    demo.launch()

You have two options:

  1. Explicitly pass interactive=True
  2. Use the component in an event as the input, and it will automatically be treated as an input and set to interactive=True