mirror of
https://github.com/gradio-app/gradio.git
synced 2025-03-25 12:10:31 +08:00
Allows setting custom <title> (#1703)
* fix title issue * formatting * docstrings and demos
This commit is contained in:
parent
92889b7b93
commit
e2cebde5e6
@ -61,7 +61,7 @@ io4 = gr.Interface(
|
||||
gr.Audio(),
|
||||
)
|
||||
|
||||
demo = gr.Blocks()
|
||||
demo = gr.Blocks(title="Neural Instrument Cloning")
|
||||
|
||||
with demo.clear():
|
||||
m(
|
||||
|
@ -1,6 +1,6 @@
|
||||
import gradio as gr
|
||||
|
||||
with gr.Blocks() as demo:
|
||||
with gr.Blocks(title="Styling Examples") as demo:
|
||||
with gr.Column():
|
||||
txt = gr.Textbox(label="Small Textbox", lines=1).style(
|
||||
rounded=False,
|
||||
|
@ -226,6 +226,7 @@ class Blocks(BlockContext):
|
||||
theme: str = "default",
|
||||
analytics_enabled: Optional[bool] = None,
|
||||
mode: str = "blocks",
|
||||
title: str = "Gradio",
|
||||
css: Optional[str] = None,
|
||||
**kwargs,
|
||||
):
|
||||
@ -234,6 +235,8 @@ class Blocks(BlockContext):
|
||||
theme (str): which theme to use - right now, only "default" is supported.
|
||||
analytics_enabled (bool | None): whether to allow basic telemetry. If None, will use GRADIO_ANALYTICS_ENABLED environment variable or default to True.
|
||||
mode (str): a human-friendly name for the kind of Blocks interface being created.
|
||||
title (str): The tab title to display when this is opened in a browser window.
|
||||
css (str | None): custom css or path to custom css file to apply to entire Blocks
|
||||
"""
|
||||
# Cleanup shared parameters with Interface #TODO: is this part still necessary after Interface with Blocks?
|
||||
self.limiter = None
|
||||
@ -272,6 +275,7 @@ class Blocks(BlockContext):
|
||||
self.auth = None
|
||||
self.dev_mode = True
|
||||
self.app_id = random.getrandbits(64)
|
||||
self.title = title
|
||||
|
||||
@property
|
||||
def share(self):
|
||||
@ -573,6 +577,7 @@ class Blocks(BlockContext):
|
||||
"components": [],
|
||||
"theme": self.theme,
|
||||
"css": self.css,
|
||||
"title": self.title or "Gradio",
|
||||
"enable_queue": getattr(
|
||||
self, "enable_queue", False
|
||||
), # attribute set at launch
|
||||
|
@ -140,7 +140,7 @@ class Interface(Blocks):
|
||||
live (bool): whether the interface should automatically rerun if any of the inputs change.
|
||||
interpretation (Callable | str): function that provides interpretation explaining prediction output. Pass "default" to use simple built-in interpreter, "shap" to use a built-in shapley-based interpreter, or your own custom interpretation function.
|
||||
num_shap (float): a multiplier that determines how many examples are computed for shap-based interpretation. Increasing this value will increase shap runtime, but improve results. Only applies if interpretation is "shap".
|
||||
title (str | None): a title for the interface; if provided, appears above the input and output components in large font.
|
||||
title (str | None): 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.
|
||||
description (str | None): a description for the interface; if provided, appears above the input and output components and beneath the title in regular font. Accepts Markdown and HTML content.
|
||||
article (str | None): an expanded article explaining the interface; if provided, appears below the input and output components in regular font. Accepts Markdown and HTML content.
|
||||
thumbnail (str | None): path or url to image to use as display image when the web demo is shared on social media.
|
||||
@ -153,7 +153,11 @@ class Interface(Blocks):
|
||||
analytics_enabled (bool | None): Whether to allow basic telemetry. If None, will use GRADIO_ANALYTICS_ENABLED environment variable if defined, or default to True.
|
||||
"""
|
||||
super().__init__(
|
||||
analytics_enabled=analytics_enabled, mode="interface", css=css, **kwargs
|
||||
analytics_enabled=analytics_enabled,
|
||||
mode="interface",
|
||||
css=css,
|
||||
title=title,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
if inspect.iscoroutinefunction(fn):
|
||||
|
Loading…
x
Reference in New Issue
Block a user