FHPythonUtils / Cli2Gui

Use this module to convert a cli program to a gui
MIT License
90 stars 7 forks source link

Feature: Populate fields with defaults #11

Closed Evidlo closed 1 year ago

Evidlo commented 2 years ago

Currently it looks like Cli2Gui doesn't make use of the default argument for argparse. It would be very nice if these showed up generated GUI.

# main.py

from cli2gui import Cli2Gui
import argparse

def run(args):
    print(args.arg)

def main():
    parser = argparse.ArgumentParser(description="this is an example parser")
    parser.add_argument("--arg", type=str, default="foo", help="keyword arg")
    parser.add_argument("--bool", action='store_true', default=True, help="boolean arg")
    args = parser.parse_args()
    run(args)

decorator_function = Cli2Gui(
    run_function=run,
    auto_enable=True,
)

gui = decorator_function(main)

if __name__ == "__main__":
    gui()

out

FredHappyface commented 2 years ago

Hi thanks for opening the issue and apologies for the delayed response (it has been a busy couple months!)

Absolutely agreed! I'll see if I can get it implemented

ByVictorrr commented 2 years ago

also, it would be nice to have dynamic command to be working like adding a command on start of that super command

FredHappyface commented 2 years ago

Not clear on what you mean? If this is a separate issue then can you create a new issue please :)