From 0ce776b1f66b5381b0a7715c2b95eec205663761 Mon Sep 17 00:00:00 2001 From: Peter Teuben Date: Fri, 29 Sep 2023 19:07:03 -0400 Subject: [PATCH] add --version; also enable option to allow extra file , which is expected to be the key file --- qtrun.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/qtrun.py b/qtrun.py index 2680878..29c297c 100755 --- a/qtrun.py +++ b/qtrun.py @@ -7,6 +7,9 @@ import re import subprocess +_version = "29-sep-2023" +_debug = False + class MainWindow(QtWidgets.QMainWindow): def __init__(self, parameters, input_file, filetype): @@ -347,16 +350,27 @@ def parsefile(file): if __name__ == '__main__': global args # global to access args outside parser = argparse.ArgumentParser(description="Dynamic GUI Builder") - parser.add_argument("input_file", help="Path to the text file containing parameters") + parser.add_argument("input_file", help="Text file containing `key=val` parameters, optionally add a keyfile", default=None, nargs='*') parser.add_argument('-d', '--debug', action='store_true', help='Enable debug mode') + parser.add_argument('-v', '--version', action='store_true', help='Show version') args = parser.parse_args() + if args.version: + print(_version) + sys.exit(0) + + _debug = args.debug - groups, filetype = parsefile(args.input_file) + input_file = args.input_file[0] + if len(args.input_file) > 1: + print("multiple args not yet supported") + if _debug: + print(input_file) + groups, filetype = parsefile(input_file) app = QtWidgets.QApplication(sys.argv) - w = MainWindow(groups, os.path.abspath(args.input_file), filetype) + w = MainWindow(groups, os.path.abspath(input_file), filetype) # w.inputFile = args.input_file w.adjustSize() #adjust to fit elements accordingly @@ -366,7 +380,9 @@ def parsefile(file): w.show() try: - print('opening window') + if _debug: + print('opening window') sys.exit(app.exec()) except SystemExit: - print('closing window') + if _debug: + print('closing window')