Respect interactive=True in output of gr.Interface (#4356)

* tests

* changelog

* lint

* Update gradio/interface.py

Co-authored-by: Aarni Koskela <akx@iki.fi>

* format

---------

Co-authored-by: Aarni Koskela <akx@iki.fi>
This commit is contained in:
Abubakar Abid 2023-05-30 09:22:03 -07:00 committed by GitHub
parent 0a6a80ce02
commit fc3bbca878
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 3 deletions

View File

@ -2,10 +2,11 @@
## New Features:
* Make `Blocks.load` behave like other event listeners (allows chaining `then` off of it) [@anentropic](https://github.com/anentropic/) in [PR 4304](https://github.com/gradio-app/gradio/pull/4304)
## Bug Fixes:
- Make `Blocks.load` behave like other event listeners (allows chaining `then` off of it) [@anentropic](https://github.com/anentropic/) in [PR 4304](https://github.com/gradio-app/gradio/pull/4304)
- Respect `interactive=True` in output components of a `gr.Interface` by [@abidlabs](https://github.com/abidlabs) in [PR 4356](https://github.com/gradio-app/gradio/pull/4356).
- Remove unused frontend code by [@akx](https://github.com/akx) in [PR 4275](https://github.com/gradio-app/gradio/pull/4275)
## Other Changes:

View File

@ -264,8 +264,10 @@ class Interface(Blocks):
]:
for o in self.output_components:
assert isinstance(o, IOComponent)
o.interactive = False # Force output components to be non-interactive
if o.interactive is None:
# Unless explicitly otherwise specified, force output components to
# be non-interactive
o.interactive = False
if (
interpretation is None
or isinstance(interpretation, list)

View File

@ -160,6 +160,14 @@ class TestInterface:
assert mock_display.call_count == 2
interface.close()
def test_setting_interactive_false(self):
output_textbox = Textbox()
Interface(lambda x: x, "textbox", output_textbox)
assert not output_textbox.get_config()["interactive"]
output_textbox = Textbox(interactive=True)
Interface(lambda x: x, "textbox", output_textbox)
assert output_textbox.get_config()["interactive"]
class TestTabbedInterface:
def test_tabbed_interface_config_matches_manual_tab(self):