Skip to content

Commit

Permalink
add --version; also enable option to allow extra file , which is expe…
Browse files Browse the repository at this point in the history
…cted to be the key file
  • Loading branch information
teuben committed Sep 29, 2023
1 parent 063605d commit 0ce776b
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions qtrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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

Expand All @@ -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')

0 comments on commit 0ce776b

Please sign in to comment.