-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build desktop apps with Gradio #2257
Comments
Hey @divamgupta thanks for the suggestion! Will discuss this with the team. Can you tell me more about the motivation here? What are the use cases where the regular Gradio web app would not suffice and a desktop app would be more useful? |
I feel there is a big demand for desktop applications. It running locally, it feels more natural to run a desktop application rather than an application opening in your web browser. I had created a small application called diffusionbee, it got popular because of this reason. It would be been cool to use a framework like gradio to build it. |
What if you could package a gradio app as a desktop app? |
I agree with you @divamgupta ! With Gradio, you can create modern looking web pages with very short code. Potential users of Gradio might be developers who are creating interactive desktop applications using the Python GUI framework like PyQt, wxPython, Tkinter or something. The use cases are many. Recently, digital transformation has increased the demand for commercial software. However, deploying commercial applications developed with Gradio to HuggingFace Spaces raises security and other concerns. And it is not practical to build a virtual environment on the user's computer so that the application can run on the user's local environment. In summary, if we can build standalone desktop apps in Gradio, we developers can build high quality apps in a short amount of time and spend our time on more meaningful things. |
LGTM. The |
One approach would be to make it possible to package a Gradio app as an executable. We could leverage For example, running:
would install pyinstaller (if needed) and then call it on the Would this address your use cases @divamgupta @petrov826 @lvelvee @CreaperLost? |
@abidlabs Thank you for your information! I install gradio version 3.39.0 using pip. Here's my super simple
Could you give me some more help? Edit: There is a slightly related issue the 'package' argument is required to perform a relative import #3057 |
Sorry @petrov826 I meant that this is the proposed approach. It’s not currently implemented in gradio |
@abidlabs I'm sorry too. I was jumping to a hasty conclusion.😅 |
Yes, this is the most common and simple way to do. |
Is this feature available now? |
I'm trying something like putting it inside electron but the above idea will be cool |
Not yet! |
will the pyinstaller method used to convert pyqt work on gradio? Till the gradio package app.py command is built? |
today marks official 1 year+ of this thread life. Deliver web apps which use user's pc resources still remains a dream. |
+1. Having standalone desktop support would be huge! Running on a standalone window is simple enough using pywebview. The real struggle seems to be the standalone packaging. Neither Pyinstaller nor Nuitka seem to work with basic configurations (some missing files or dependencies related to Gradio). Has anyone successfully packaged a gradio app? |
@abidlabs This is a great feature that can increase the reach of Gradio. Is this in the roadmap? |
Thanks @hypoechoic I agree it could be interesting to explore. We've had some community contributors who are interested in this as well as are looking into it but don't really have an eta at this time. Happy to discuss more if you're interested in contributing in this direction |
@abidlabs I'm interested in contributing with some guidance I'm new to complex opensource projects. |
Hi @thunder-007 thanks for your interest! This is a relatively complex issue so I'd suggest picking one of the issues labeled "good first issue" if you are new to complex opensource projects. |
Can you share basic code, how can this be done, im first time building desktop application and dont know how to integrate gradio with pywebview. Regards |
Not sure about the third party solutions discussed in this thread but we are planning on supporting this in the future with gradio-lite see #7032 for more info |
up |
up :D |
Hi @borisalmonacid this isn't on our immediate roadmap, although if you can share a little more about your use case, it might help us figure out how to prioritize this in our long-term plans |
I managed to do a simple gradio with pywebview. It takes time for the initial launch though since it takes time for pywebview to open import sys
from concurrent.futures import ProcessPoolExecutor
from pathlib import Path
import gradio as gr
import webview
def greet(name):
return "Hello " + name + "!"
def gui():
with gr.Blocks() as demo:
with gr.Tab(label="Tab 1"):
name = gr.Textbox(label="Name")
output = gr.Textbox(label="Output Box")
greet_btn = gr.Button("Greet")
greet_btn.click(fn=greet, inputs=name, outputs=output, api_name="greet")
with gr.Tab(label="Tab 2"):
name2 = gr.Textbox(label="Name", show_copy_button=True)
output2 = gr.Textbox(label="Output")
demo.launch(prevent_thread_lock=True)
def on_window_close():
sys.exit()
def launch_webview():
window = webview.create_window("App", "http://localhost:7860/")
window.events.closed += on_window_close
webview.start()
if __name__ == "__main__":
with ProcessPoolExecutor() as executor:
executor.submit(gui)
executor.submit(launch_webview) |
Cool! Cc @whitphx something to explore after 5.0 launch |
UP! I'm also trying to do this with PyInstaller and no matter what I do, I can't seem to add every package needed. Latest is a missing blocks_events.py. |
UP! :) |
@csanadpoda , I did manage to build a pretty complex cross-platform desktop app using Gradio and Pyinstaller. I solved the issues with packaging Gradio thanks to the comments under this issue from Pyinstaller repository. |
I'm working on packaging Gradio + PyWebView with PyInstaller to create an executable that launches a Gradio app and opens a webview window. Also thinking of making a one-stop command to do it. |
Would be cool for developers to create desktop apps using Gradio!
The text was updated successfully, but these errors were encountered: