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

Question: Is it possible to override argument defaults with supplied command line argument values? #26

Open
laser101 opened this issue Dec 20, 2024 · 0 comments
Assignees
Labels
question Further information is requested

Comments

@laser101
Copy link

laser101 commented Dec 20, 2024

If the user provides command line arguments when starting the program, then I would like to use these values to override the defaults shown in the GUI. Is this possible? Currently it seems that Cli2Gui ignores these command line arguments when using the decorator approach such as the example below.

If the code below was called as python myapp -name me -age 18 then I would expect the GUI to showme in the name textbox and 18 in the age textbox as the default response. Instead we see a blank name and age 21...

image

Basically I am seeking the functionality offered by Gooey through the use_cmd_args parameter. See description here.

Thank you.

import argparse
from cli2gui import Cli2Gui

# Define the function that will handle the program's logic
def run(args):
    print(args.arg)

# Use Cli2Gui as a decorator to convert CLI into a GUI, using deargui
@Cli2Gui(run_function=run, gui="deargui", auto_enable=True)
def main():
    parser = argparse.ArgumentParser(description="Example parser with GUI support")
    parser.add_argument("--name", help="Enter your name", required=True)
    parser.add_argument("--age", type=int, default=21, help="Enter your age")
    args = parser.parse_args()
    run(args)

if __name__ == "__main__":
    main()
@laser101 laser101 added the question Further information is requested label Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants