A real quick GUI generator for click. Inspired by Gooey, the GUI generator for classical Python argparse
-based command line programs.
python setup.py install
Open your terminal, go into the downloaded source folder and input
python test.py
Then click "Run" button. You will see something like this.
Open test.py
to see what the original click-based program looks like.
This package could draw the gui for a click-based CLI program with a very
simple function gui_it
. The usage is wrapping the command function
example_cmd()
like gui_it(example_cmd)
. The full example is like
this.
from quick import gui_it
import click
@click.command()
@click.option("--hello", default="world", help="say hello")
@click.option("--add", type=int, help="input an integer number",\
hide_input=True)
@click.option("--minus", type=float, help="input two numbers", nargs=2)
@click.option("--flag", is_flag=True)
@click.option('--shout/--no-shout', default=True)
@click.option('--language', type=click.Choice(['c', 'c++']))
@click.option('-v', '--verbose', count=True)
def example_cmd(**argvs):
for k, v in argvs.items():
print(k, v, type(v))
if __name__ == "__main__":
# example_cmd()
gui_it(example_cmd)
A common case is not changing all your command into a gui version, but just
add a --gui
option to it. Then you can do this.
from quick import gui_option
import click
@gui_option()
@click.group()
@click.option('--debug/--no-debug', default=False)
def cli(debug):
print(debug)
@cli.command()
@click.argument("arg", nargs=-1)
@click.option("--hello", default="world", help="say hello")
@click.option('-v', '--verbose', count=True)
def example_cmd(**argvs):
for k, v in argvs.items():
print(k, v, type(v))
@cli.command()
@click.option("--hello")
def sync(hello):
print('Synching', hello)
@cli.command()
def func(**argvs):
pass
if __name__ == "__main__":
cli()
Travis CI is used for continuous integration.
see LICENCE