Open pmbarrett314 opened 1 month ago
Hi @pmbarrett314, I think this would be a great case for a custom component!
we've made it possible for Gradio users to create their own custom components (using existing components, like gr.FileExplorer as a base template) -- meaning that you can write some Python and JavaScript (Svelte), and publish it as a Gradio component. You can use it in your own Gradio apps, or share it so that anyone can use it in their Gradio apps.
Here's an example of a Gradio custom component: https://github.com/PhyscalX/gradio-image-prompter -- it lets you upload images and process points or draw boxes on top of the image.
If you'd like to create your own, we've put together a Guide: https://www.gradio.app/guides/five-minute-guide, and we're happy to help.
I'd been working with custom components as well! Scope-wise, I was on the fence about whether at least some of this might make sense as an update to the built-in component. I will definitely work on it as a custom component when I get to it.
Thanks @pmbarrett314, looking forward for your custom component! I'll keep this issue open and cc @aliabid94 for this thoughts.
Regex support in FileExplorer. Glob is fine, but falls apart as soon as you want two types of file. Especially since components like Video supports multiple file types I think a bit more robustness is needed. Maybe just a regex field for the FileExplorer component initializer that defaults to None and overrides the glob and ignore_glob fields if it's truthy?
Maybe we could accept a list of globs, not just a single glob
Support showing some files without allowing selecting them.
Partial interactivity feels like a case for a custom component
Also in general allowing directories and files to be selected at the same time can be problematic if the value is being passed to something that expects one or the other..
Agreed, I thought we already supported this, but it seems not.
Is your feature request related to a problem? Please describe.
The workflow I'm trying to support is something along the lines allowing the user to select a directory while only showing certain filetypes as context to aid in selecting the correct directory. So for example I have a folder hierarchy that contains videos, images, and possibly other random files like txt files or
.DS_Store
. I would like only the directories to be selectable, but I would like to show the video files so the user has more context than just the directory name.Describe the solution you'd like
I have a couple of ideas.
FileExplorer
. Glob is fine, but falls apart as soon as you want two types of file. Especially since components likeVideo
supports multiple file types I think a bit more robustness is needed. Maybe just aregex
field for theFileExplorer
component initializer that defaults toNone
and overrides theglob
andignore_glob
fields if it's truthy?.
UI is fine for me, but even some relatively technical end-users will likely find it confusing and I have to believe there's a more intuitive way to do it. Also in general allowing directories and files to be selected at the same time can be problematic if the value is being passed to something that expects one or the other..