chriskiehl / Gooey

Turn (almost) any Python command line program into a full GUI application with one line

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can I use a loop to execute some commands?

rayrayraykk opened this issue · comments

Thanks for the great work!
I need to save some global variables after executing a command and continue to modify this global variable in the next command. It seems that the program exits or re-executes when it finishes executing. Is there a way to make my program LOOP run?

For example:

while True:
    args.cmd = input()
    if args.cmd == '1':
        ...
    elif args.cmd == '2':
        ...
    else:
        ...

In other words, how can I share a variable between two independent actions?

Thanks for the great work! I need to save some global variables after executing a command and continue to modify this global variable in the next command. It seems that the program exits or re-executes when it finishes executing. Is there a way to make my program LOOP run?

For example:

while True:
    args.cmd = input()
    if args.cmd == '1':
        ...
    elif args.cmd == '2':
        ...
    else:
        ...

In other words, how can I share a variable between two independent actions?

Hi, maybe you could try dumping that variable to a file, for example using Pickle? It will persist between executions of your program. There are some nice examples in here.