Skip to content
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

Toga-based CLI-to-GUI builder? #2685

Closed
twardoch opened this issue Jul 1, 2024 · 1 comment
Closed

Toga-based CLI-to-GUI builder? #2685

twardoch opened this issue Jul 1, 2024 · 1 comment
Labels
enhancement New features, or improvements to existing features.

Comments

@twardoch
Copy link

twardoch commented Jul 1, 2024

What is the problem or limitation you are having?

Trogon uses Textual to automatically builds TUIs from Click CLI apps:
https://github.com/Textualize/trogon

and even from Typer CLI apps (via click):
Textualize/trogon#10 (comment)

I know Toga has its own textual backend plus other backends. So if Trogon were ported to Toga (rather than being based on Textual), one could go Typer -> Click -> Toga -> ...

Describe the solution you'd like

A "port" of Trogon to Toga, as a separate package

Describe alternatives you've considered

I've used Gooey for rapid automatic building of GUI from CLI, but Gooey relies on argparse more-less directly, and while quite feature-rich, it's also a bit antiquated.

Typer uses Click insert the hood but allows very simple declarative CLI definitions and Trogon already does a decent job at building a TUI from Click & Typer, but it's limited to TUI.

Toga looks like a great package for single-source cross-platform TUI+GUI building, and by adapting Trogon to Toga, we could have a very powerful yet extremely simple to use GUI builder that could be easily "injected" into existing Click CLI apps.

Additional context

No response

@twardoch twardoch added the enhancement New features, or improvements to existing features. label Jul 1, 2024
@freakboy3742
Copy link
Member

I agree that Toga would be a good match for this sort of functionality. Being able to generate a GUI or TUI (or, for that matter, web) frontend for a command line script sounds extremely interesting. There's actually an interesting crossover with #90 - the mechanisms needed to convert a "command line specification" and an abstract definition of settings into a GUI representation should be quite similar.

However, the specific feature (an app bootstrap) wouldn't be part of Toga itself. It makes a lot more sense as something to add as an option on Trogon/Gooey/Typer.

Alternatively, it might make an interesting bootstrap plugin for Briefcase. We've recently added a "bootstrap plugin" API to Briefcase that allows the plugin to inject app logic into a new app. We're using it for testing purposes - injecting "shut down after 2 seconds" logic so we can test that a Briefcase generated app can start; we anticipated someone eventually writing a "Positron" plugin that can convert a website into an app. A similar plugin to convert a click/argparse definition would also be interesting.

However, in either case, there's nothing actionable for Toga; on that basis, I'm going to close this issue. If this is an area where you're interested, I'd strongly encourage you to pursue it - we're happy to provide any assistance or suggestions; and if there's changes that need to be made to Toga or Briefcase to make this more plausible, we're definitely open to those discussions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New features, or improvements to existing features.
Projects
None yet
Development

No branches or pull requests

2 participants