Fix blocks_style demo (#2890)

* Fix blocks_style demo

* Add changelog

* Fix API + notebook

* Remove nested column

* moved highlighttext colormap to style

* Add back container

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
This commit is contained in:
Freddy Boulton 2022-12-27 11:51:08 -05:00 committed by GitHub
parent e3434dd4cb
commit e7cca92831
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 72 deletions

View File

@ -7,7 +7,8 @@
* 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)
* Fixed bug where csv preview for DataFrame examples would show filename instead of file contents by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 2877](https://github.com/gradio-app/gradio/pull/2877)
* Fixed bug where an error raised after yielding iterative output would not be displayed in the browser by
[@JaySmithWpg](https://github.com/JaySmithWpg) in [PR 2889](https://github.com/gradio-app/gradio/pull/2889)
[@JaySmithWpg](https://github.com/JaySmithWpg) in [PR 2889](https://github.com/gradio-app/gradio/pull/2889)
* Fixed bug in `blocks_style` demo that was preventing it from launching by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 2876](https://github.com/gradio-app/gradio/pull/2890)
## Documentation Changes:
* Added a Guide on using Google Sheets to create a real-time dashboard with Gradio's `DataFrame` and `LinePlot` component, by [@abidlabs](https://github.com/abidlabs) in [PR 2816](https://github.com/gradio-app/gradio/pull/2816)

View File

@ -1 +1 @@
{"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: blocks_style"]}, {"cell_type": "code", "execution_count": null, "id": 272996653310673477252411125948039410165, "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": 288918539441861185822528903084949547379, "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "\n", "with gr.Blocks(title=\"Styling Examples\") as demo:\n", " with gr.Column():\n", " txt = gr.Textbox(label=\"Small Textbox\", lines=1).style(\n", " rounded=False,\n", " border=False,\n", " container=False,\n", " )\n", "\n", " num = gr.Number(label=\"Number\", show_label=False).style(\n", " rounded=False,\n", " border=False,\n", " container=False,\n", " )\n", " slider = gr.Slider(label=\"Slider\", show_label=False).style(\n", " container=False,\n", " )\n", " check = gr.Checkbox(label=\"Checkbox\", show_label=False).style(\n", " rounded=False,\n", " border=False,\n", " container=False,\n", " )\n", " check_g = gr.CheckboxGroup(\n", " label=\"Checkbox Group\", choices=[\"One\", \"Two\", \"Three\"], show_label=False\n", " ).style(rounded=False, container=False, item_container=False)\n", " radio = gr.Radio(\n", " label=\"Radio\", choices=[\"One\", \"Two\", \"Three\"], show_label=False\n", " ).style(\n", " item_container=False,\n", " container=False,\n", " )\n", " drop = gr.Dropdown(\n", " label=\"Dropdown\", choices=[\"One\", \"Two\", \"Three\"], show_label=False\n", " ).style(\n", " rounded=False,\n", " border=False,\n", " container=False,\n", " )\n", " image = gr.Image(show_label=False).style(\n", " rounded=False,\n", " )\n", " video = gr.Video(show_label=False).style(\n", " rounded=False,\n", " )\n", " audio = gr.Audio(show_label=False).style(\n", " rounded=False,\n", " )\n", " file = gr.File(show_label=False).style(\n", " rounded=False,\n", " )\n", " df = gr.Dataframe(show_label=False).style(\n", " rounded=False,\n", " )\n", "\n", " ts = gr.Timeseries(show_label=False).style(\n", " rounded=False,\n", " )\n", " label = gr.Label().style(\n", " container=False,\n", " )\n", " highlight = gr.HighlightedText(\n", " \"+ hello. - goodbye\", show_label=False, color_map={\"+\": \"green\", \"-\": \"red\"}\n", " ).style(rounded=False, container=False)\n", " json = gr.JSON().style(container=False)\n", " html = gr.HTML(show_label=False).style()\n", " gallery = gr.Gallery().style(\n", " rounded=False,\n", " grid=(3, 3, 1),\n", " height=\"auto\",\n", " container=False,\n", " )\n", " chat = gr.Chatbot(\"hi\", color_map=(\"pink\", \"blue\")).style(\n", " rounded=False,\n", " )\n", "\n", " model = gr.Model3D().style(\n", " rounded=False,\n", " )\n", "\n", " gr.Plot().style()\n", " md = gr.Markdown(show_label=False).style()\n", "\n", " highlight = gr.HighlightedText().style(\n", " rounded=False,\n", " )\n", "\n", " btn = gr.Button(\"Run\").style(\n", " rounded=False,\n", " full_width=True,\n", " border=False,\n", " )\n", "\n", " # Not currently public\n", " # TODO: Uncomment at next release\n", " # gr.Dataset().style(\n", " # rounded=False,\n", " # margin=False,\n", " # border=False,\n", " # )\n", "\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
{"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: blocks_style"]}, {"cell_type": "code", "execution_count": null, "id": 272996653310673477252411125948039410165, "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": 288918539441861185822528903084949547379, "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "\n", "with gr.Blocks(title=\"Styling Examples\") as demo:\n", " with gr.Column(variant=\"box\"):\n", " txt = gr.Textbox(label=\"Small Textbox\", lines=1)\n", " num = gr.Number(label=\"Number\", show_label=False)\n", " slider = gr.Slider(label=\"Slider\", show_label=False)\n", " check = gr.Checkbox(label=\"Checkbox\", show_label=False)\n", " check_g = gr.CheckboxGroup(\n", " label=\"Checkbox Group\",\n", " choices=[\"One\", \"Two\", \"Three\"],\n", " show_label=False,\n", " )\n", " radio = gr.Radio(\n", " label=\"Radio\", choices=[\"One\", \"Two\", \"Three\"], show_label=False\n", " ).style(\n", " item_container=False,\n", " )\n", " drop = gr.Dropdown(\n", " label=\"Dropdown\", choices=[\"One\", \"Two\", \"Three\"], show_label=False\n", " )\n", " image = gr.Image(show_label=False)\n", " video = gr.Video(show_label=False)\n", " audio = gr.Audio(show_label=False)\n", " file = gr.File(show_label=False)\n", " df = gr.Dataframe(show_label=False)\n", " ts = gr.Timeseries(show_label=False)\n", " label = gr.Label().style(\n", " container=False,\n", " )\n", " highlight = gr.HighlightedText(\n", " \"+ hello. - goodbye\",\n", " show_label=False,\n", " ).style(color_map={\"+\": \"green\", \"-\": \"red\"}, container=False)\n", " json = gr.JSON().style(container=False)\n", " html = gr.HTML(show_label=False)\n", " gallery = gr.Gallery().style(\n", " grid=(3, 3, 1),\n", " height=\"auto\",\n", " container=False,\n", " )\n", " chat = gr.Chatbot([(\"hi\", \"good bye\")]).style(color_map=(\"pink\", \"blue\"))\n", "\n", " model = gr.Model3D()\n", "\n", " md = gr.Markdown(show_label=False)\n", "\n", " highlight = gr.HighlightedText()\n", "\n", " btn = gr.Button(\"Run\").style(\n", " full_width=True,\n", " )\n", "\n", " gr.Dataset(components=[txt, num])\n", "\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}

View File

@ -1,103 +1,57 @@
import gradio as gr
with gr.Blocks(title="Styling Examples") as demo:
with gr.Column():
txt = gr.Textbox(label="Small Textbox", lines=1).style(
rounded=False,
border=False,
container=False,
)
num = gr.Number(label="Number", show_label=False).style(
rounded=False,
border=False,
container=False,
)
slider = gr.Slider(label="Slider", show_label=False).style(
container=False,
)
check = gr.Checkbox(label="Checkbox", show_label=False).style(
rounded=False,
border=False,
container=False,
)
with gr.Column(variant="box"):
txt = gr.Textbox(label="Small Textbox", lines=1)
num = gr.Number(label="Number", show_label=False)
slider = gr.Slider(label="Slider", show_label=False)
check = gr.Checkbox(label="Checkbox", show_label=False)
check_g = gr.CheckboxGroup(
label="Checkbox Group", choices=["One", "Two", "Three"], show_label=False
).style(rounded=False, container=False, item_container=False)
label="Checkbox Group",
choices=["One", "Two", "Three"],
show_label=False,
)
radio = gr.Radio(
label="Radio", choices=["One", "Two", "Three"], show_label=False
).style(
item_container=False,
container=False,
)
drop = gr.Dropdown(
label="Dropdown", choices=["One", "Two", "Three"], show_label=False
).style(
rounded=False,
border=False,
container=False,
)
image = gr.Image(show_label=False).style(
rounded=False,
)
video = gr.Video(show_label=False).style(
rounded=False,
)
audio = gr.Audio(show_label=False).style(
rounded=False,
)
file = gr.File(show_label=False).style(
rounded=False,
)
df = gr.Dataframe(show_label=False).style(
rounded=False,
)
ts = gr.Timeseries(show_label=False).style(
rounded=False,
)
image = gr.Image(show_label=False)
video = gr.Video(show_label=False)
audio = gr.Audio(show_label=False)
file = gr.File(show_label=False)
df = gr.Dataframe(show_label=False)
ts = gr.Timeseries(show_label=False)
label = gr.Label().style(
container=False,
)
highlight = gr.HighlightedText(
"+ hello. - goodbye", show_label=False, color_map={"+": "green", "-": "red"}
).style(rounded=False, container=False)
"+ hello. - goodbye",
show_label=False,
).style(color_map={"+": "green", "-": "red"}, container=False)
json = gr.JSON().style(container=False)
html = gr.HTML(show_label=False).style()
html = gr.HTML(show_label=False)
gallery = gr.Gallery().style(
rounded=False,
grid=(3, 3, 1),
height="auto",
container=False,
)
chat = gr.Chatbot("hi", color_map=("pink", "blue")).style(
rounded=False,
)
chat = gr.Chatbot([("hi", "good bye")]).style(color_map=("pink", "blue"))
model = gr.Model3D().style(
rounded=False,
)
model = gr.Model3D()
gr.Plot().style()
md = gr.Markdown(show_label=False).style()
md = gr.Markdown(show_label=False)
highlight = gr.HighlightedText().style(
rounded=False,
)
highlight = gr.HighlightedText()
btn = gr.Button("Run").style(
rounded=False,
full_width=True,
border=False,
)
# Not currently public
# TODO: Uncomment at next release
# gr.Dataset().style(
# rounded=False,
# margin=False,
# border=False,
# )
gr.Dataset(components=[txt, num])
if __name__ == "__main__":