Add title to TabbedInterface (#2888)

* Add title to `TabbedInterface`

* Add title to the header of interface

* Add the new title feature to changelog
This commit is contained in:
Mohamed Rashad 2022-12-27 02:52:33 +02:00 committed by GitHub
parent 88c9206159
commit 21820f47ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -1,7 +1,7 @@
# Upcoming Release
## New Features:
No changes to highlight.
* Added `title` argument to `TabbedInterface` by @MohamedAliRashad in [#2888](https://github.com/gradio-app/gradio/pull/2888)
## Bug Fixes:
* Fixed bug where setting `default_enabled=False` made it so that the entire queue did not start by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 2876](https://github.com/gradio-app/gradio/pull/2876)

View File

@ -726,6 +726,7 @@ class TabbedInterface(Blocks):
self,
interface_list: List[Interface],
tab_names: Optional[List[str]] = None,
title: Optional[str] = None,
theme: str = "default",
analytics_enabled: Optional[bool] = None,
css: Optional[str] = None,
@ -734,6 +735,7 @@ class TabbedInterface(Blocks):
Parameters:
interface_list: a list of interfaces to be rendered in tabs.
tab_names: a list of tab names. If None, the tab names will be "Tab 1", "Tab 2", etc.
title: a title for the interface; if provided, appears above the input and output components in large font. Also used as the tab title when opened in a browser window.
theme: which theme to use - right now, only "default" is supported.
analytics_enabled: whether to allow basic telemetry. If None, will use GRADIO_ANALYTICS_ENABLED environment variable or default to True.
css: custom css or path to custom css file to apply to entire Blocks
@ -741,6 +743,7 @@ class TabbedInterface(Blocks):
a Gradio Tabbed Interface for the given interfaces
"""
super().__init__(
title=title,
theme=theme,
analytics_enabled=analytics_enabled,
mode="tabbed_interface",
@ -749,6 +752,12 @@ class TabbedInterface(Blocks):
if tab_names is None:
tab_names = ["Tab {}".format(i) for i in range(len(interface_list))]
with self:
if title:
Markdown(
"<h1 style='text-align: center; margin-bottom: 1rem'>"
+ title
+ "</h1>"
)
with Tabs():
for (interface, tab_name) in zip(interface_list, tab_names):
with TabItem(label=tab_name):