gradio
Add toolbar with fullscreen button to `gr.Dataframe`
#10377
Merged

Add toolbar with fullscreen button to `gr.Dataframe` #10377

abidlabs merged 22 commits into main from df-toolbar
hannahblair
hannahblair133 days ago (edited 132 days ago)

Description

Screenshot 2025-01-16 at 17 42 46

Closes: #7423

🎯 PRs Should Target Issues

Before your create a PR, please check to see if there is an existing issue for this change. If not, please create an issue before you create this PR, unless the fix is very small.

Not adhering to this guideline will result in the PR being closed.

Testing and Formatting Your Code

  1. PRs will only be merged if tests pass on CI. We recommend at least running the backend tests locally, please set up your Gradio environment locally and run the backed tests: bash scripts/run_backend_tests.sh

  2. Please run these bash scripts to automatically format your code: bash scripts/format_backend.sh, and (if you made any changes to non-Python files) bash scripts/format_frontend.sh

hannahblair add toolbar with full screen and copy button
d01d0b87
hannahblair hannahblair marked this pull request as draft 133 days ago
gradio-pr-bot
gradio-pr-bot133 days ago (edited 129 days ago)

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website building...
Storybook ready! Storybook preview
🦄 Changes detected! Details

Install Gradio from this PR

pip install https://gradio-pypi-previews.s3.amazonaws.com/435757b2341628a816dc6fd694ed300f4c7cf585/gradio-5.12.0-py3-none-any.whl

Install Gradio Python Client from this PR

pip install "gradio-client @ git+https://github.com/gradio-app/gradio@435757b2341628a816dc6fd694ed300f4c7cf585#subdirectory=client/python"

Install Gradio JS Client from this PR

npm install https://gradio-npm-previews.s3.amazonaws.com/435757b2341628a816dc6fd694ed300f4c7cf585/gradio-client-1.10.0.tgz

Use Lite from this PR

<script type="module" src="https://gradio-lite-previews.s3.amazonaws.com/435757b2341628a816dc6fd694ed300f4c7cf585/dist/lite.js""></script>
gradio-pr-bot add changeset
5bcc789a
gradio-pr-bot
gradio-pr-bot133 days ago (edited 129 days ago)

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
@gradio/dataframe minor
gradio minor
  • Maintainers can select this checkbox to manually select packages to update.

With the following changelog entry.

Add toolbar with fullscreen button to gr.Dataframe

Maintainers or the PR author can modify the PR title to modify this entry.

Something isn't right?

  • Maintainers can change the version label to modify the version bump.
  • If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can update the changelog file directly.
hannahblair add params and move toolbar to new file
481917c0
hannahblair Merge branch 'df-toolbar' of github.com:gradio-app/gradio into df-too…
dcab2096
hannahblair remove copy button for now
b2d6a040
hannahblair hannahblair changed the title Add toolbar with fullscreen button and copy button to `gr.Dataframe` Add toolbar with fullscreen button to `gr.Dataframe` 132 days ago
hannahblair Merge branch 'main' into df-toolbar
dbbc388f
hannahblair hannahblair marked this pull request as ready for review 132 days ago
hannahblair add story
98ab08bf
hannahblair Merge branch 'df-toolbar' of github.com:gradio-app/gradio into df-too…
8369172a
gradio-pr-bot add changeset
3cba80db
hannahblair test
3bf73560
hannahblair Merge branch 'df-toolbar' of github.com:gradio-app/gradio into df-too…
b6d8251e
hannahblair tweak
961a2a75
abidlabs
abidlabs132 days ago

@hannahblair does this PR add the copy button or not? I see the full screen button but not the copy values button:

import numpy as np

import gradio as gr

def transpose(matrix):
    return matrix.T

demo = gr.Interface(
    transpose,
    gr.Dataframe(type="numpy", datatype="number", row_count=5, col_count=3, show_fullscreen_button=True),
    "numpy",
    examples=[
        [np.zeros((3, 3)).tolist()],
        [np.ones((2, 2)).tolist()],
        [np.random.randint(0, 10, (3, 10)).tolist()],
        [np.random.randint(0, 10, (10, 3)).tolist()],
        [np.random.randint(0, 10, (10, 10)).tolist()],
    ],
    cache_examples=False
)

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

Also I would have expected the full screen icon to be at the same level as the label but its appearing a bit below it^

hannahblair Merge branch 'main' into df-toolbar
7a3b5dd4
hannahblair tweak
a1413b3a
hannahblair story fix
9753720d
hannahblair Merge branch 'main' into df-toolbar
380c8d6d
hannahblair test
a9db3c2a
hannahblair
hannahblair132 days ago (edited 132 days ago)

actually do we think it makes sense to add this show_fullscreen_button param to a new toolbar_options dict so it's less cluttered down the line?

abidlabs
abidlabs132 days ago👍 1

actually do we think it makes sense to add this show_fullscreen_button param to a new toolbar_options dict so it's less cluttered down the line?

I was thinking the same, although it'd be inconsistent with other components (e.g. Image has show_download_button and show_fullscreen_button). My thinking is that we have individual parameters for now, but we can refactor this across all of our components in 6.0 with a cleaner api.

hannahblair tweak
53d133e9
hannahblair
hannahblair132 days ago👍 1

I was thinking the same, although it'd be inconsistent with other components (e.g. Image has show_download_button and show_fullscreen_button). My thinking is that we have individual parameters for now, but we can refactor this across all of our components in 6.0 with a cleaner api.

oki sounds good!

does this PR add the copy button or not? I see the full screen button but not the copy values button:

oop i should've updated the description - i wanted to move the copy button to a new PR

abidlabs
abidlabs132 days ago

oop i should've updated the description - i wanted to move the copy button to a new PR

sounds good. maybe we should even consider replacing the copy button with a download-as-csv button and instead support much nicer copying of any range of cells directly using cmd-c or through the context menu

abidlabs
abidlabs132 days ago
image

Ok then besides the positioning issue above, everything looks as expected

abidlabs abidlabs requested a review from abidlabs abidlabs 129 days ago
abidlabs changes
9cee35d0
abidlabs Merge branch 'main' into df-toolbar
35757b0b
abidlabs changes
2f101ec0
abidlabs Merge branch 'df-toolbar' of github.com:gradio-app/gradio into df-too…
435757b2
abidlabs
abidlabs129 days ago

I pushed a change to fix the style tweak as @hannahblair is ooo. I think everything looks good now, but perhaps @pngwn or @aliabid94 can give the fe changes a lookover:

image
abidlabs abidlabs requested a review from aliabid94 aliabid94 129 days ago
abidlabs abidlabs requested a review from pngwn pngwn 129 days ago
abidlabs
abidlabs approved these changes on 2025-01-21
dawoodkhan82 dawoodkhan82 requested a review from dawoodkhan82 dawoodkhan82 128 days ago
dawoodkhan82
dawoodkhan82 approved these changes on 2025-01-21
dawoodkhan82128 days ago

lgtm! Although I feel like the show_fullscreen_button flag should be True by default

abidlabs
abidlabs128 days ago (edited 128 days ago)

Thanks @dawoodkhan82! I considered that but since the button takes up vertical space above the component, that could displace the layouts of Gradio apps that have a dataframe without a label. We could make this change in 6.0 though

abidlabs abidlabs merged feb1e81e into main 128 days ago
abidlabs abidlabs deleted the df-toolbar branch 128 days ago

Login to write a write a comment.

Login via GitHub

Assignees
No one assigned
Labels
Milestone