From f338f9312ce5a22896aa01d8a1f2a716d02d65f6 Mon Sep 17 00:00:00 2001 From: KylieGong Date: Thu, 7 Sep 2023 01:32:26 -0400 Subject: [PATCH 1/5] ./ not needed for run --- qtrun.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/qtrun.py b/qtrun.py index 7ec0241..5de302e 100644 --- a/qtrun.py +++ b/qtrun.py @@ -61,14 +61,15 @@ def initUI(self): # runs the file. takes the input file and runs it, piping the set paraments into the file as args def run(self): + print("running: " + self.input_file) contents = self.gather_data() - param = "" + param = self.input_file for line in contents: for key, value in line.items(): - param += f"{key}={value} " - subprocess.run([self.input_file_type, self.input_file] + param.split()) + param += f" {key}={value}" + subprocess.run(param.split()) - # saves the options into a separate file named inputfilename.key. Thiswill be saved in the format + # saves the options into a separate file named inputfilename.key. This will be saved in the format # key=value and formatted according to the input file type. def save(self): contents = self.gather_data() @@ -124,7 +125,6 @@ def load(self): def quit(self): self.close() - print('quit') def help(self): print('help') @@ -219,7 +219,8 @@ def createWidgetsFromGroups(self): slider.setValue(int(float(default_option[0])*multiplier)) slider_label = QtWidgets.QLabel(f"{slider.value()/multiplier}", self) - slider.valueChanged.connect(lambda: self.updateLabel()) + + slider.valueChanged.connect(lambda: self.update_label()) # updates to current value slider.setObjectName(group_name) self.slider_multiplier.append(multiplier) self.sliders.append((slider, slider_label, multiplier)) @@ -234,7 +235,7 @@ def createWidgetsFromGroups(self): separator.setFixedHeight(1) # Set a fixed height for the separator self.pagelayout.addWidget(separator) - def updateLabel(self): + def update_label(self): for slider, label, multiplier in self.sliders: label.setText(f"{slider.value()/multiplier}") @@ -337,8 +338,9 @@ def parsefile(file): groups, filetype = parsefile(args.input_file) app = QtWidgets.QApplication(sys.argv) - w = MainWindow(groups, args.input_file, filetype) - w.inputFile = args.input_file + + w = MainWindow(groups, os.path.abspath(args.input_file), filetype) + # w.inputFile = args.input_file w.adjustSize() #adjust to fit elements accordingly #sets a minimum window size From 980d746c262c7379054fe2d1f4b0bfe169de28a6 Mon Sep 17 00:00:00 2001 From: KylieGong Date: Thu, 7 Sep 2023 13:45:46 -0400 Subject: [PATCH 2/5] fied an error with file browsing --- qtrun.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/qtrun.py b/qtrun.py index 5de302e..830513a 100644 --- a/qtrun.py +++ b/qtrun.py @@ -11,9 +11,9 @@ def __init__(self, parameters, input_file, filetype): super(MainWindow, self).__init__() self.groups = parameters - self.radio_groups = [] self.input_file = input_file self.input_file_type = filetype + self.radio_groups = [] self.slider_multiplier = [] self.sliders = [] @@ -135,7 +135,7 @@ def createWidgetsFromGroups(self): group_type, group_name, options, default_option, help = group if group_type == "RADIO": - print("radio button created") + # print("radio button created") new_group = QtWidgets.QButtonGroup() self.radio_groups.append(new_group) group_layout = QtWidgets.QHBoxLayout() @@ -165,15 +165,16 @@ def createWidgetsFromGroups(self): txt.setText(default_option) txt.setObjectName(group_name) if group_type == "OFILE" or group_type == "IFILE": - btn.clicked.connect(lambda edit=txt: self.browse("FILE", edit)) + self.ofile = group_name + btn.clicked.connect(lambda _, edit=txt: self.browse("FILE", edit)) else: - btn.clicked.connect(lambda edit=txt: self.browse("DIR", edit)) + btn.clicked.connect(lambda _, edit=txt: self.browse("DIR", edit)) group_layout.addWidget(btn) group_layout.addWidget(txt) self.pagelayout.addLayout(group_layout) elif group_type == "CHECK": - print("checkbox created") + # print("checkbox created") group_layout = QtWidgets.QHBoxLayout() label = QtWidgets.QLabel(group_name+":") label.setToolTip(help) @@ -188,7 +189,7 @@ def createWidgetsFromGroups(self): self.pagelayout.addLayout(group_layout) elif group_type == "ENTRY": - print("textbox created") + # print("textbox created") group_layout = QtWidgets.QHBoxLayout() label = QtWidgets.QLabel(group_name+":") label.setToolTip(help) @@ -207,7 +208,7 @@ def createWidgetsFromGroups(self): options = ''.join(options) options = options.split(':') - print("slider created") + # print("slider created") #creates a horizontal decimal slider decimals = len(str(options[2]).split('.')[1]) if '.' in str(options[2]) else 0 multiplier = 10**decimals @@ -243,7 +244,6 @@ def browse(self, gtype, txt): options = QtWidgets.QFileDialog.Options() file = None dir = None - if gtype == 'FILE': file, _ = QtWidgets.QFileDialog.getOpenFileName(self, "Choose a File", "", "All Files (*)", options=options) if gtype == 'DIR': @@ -252,8 +252,9 @@ def browse(self, gtype, txt): txt.setText(file) print(file + " selected") if dir: - print(f"{dir} selected") - + txt.setText(dir) + print(dir + " selected") + def gather_data(self): layout_data = [] From e9e9cba5401e4b5cd366cda80ad279bb71894605 Mon Sep 17 00:00:00 2001 From: KylieGong Date: Sat, 9 Sep 2023 01:14:38 -0400 Subject: [PATCH 3/5] fixed slider initialization --- qtrun.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qtrun.py b/qtrun.py index 830513a..973ac63 100644 --- a/qtrun.py +++ b/qtrun.py @@ -207,6 +207,7 @@ def createWidgetsFromGroups(self): group_layout.addWidget(label) options = ''.join(options) options = options.split(':') + print(default_option) # print("slider created") #creates a horizontal decimal slider @@ -217,7 +218,7 @@ def createWidgetsFromGroups(self): slider.setSingleStep(int(float(options[2])*multiplier)) slider.setPageStep(int(float(options[2])*multiplier)) #moves the slider when clicking or up/down slider.setRange(int(options[0])*multiplier, int(options[1])*multiplier) - slider.setValue(int(float(default_option[0])*multiplier)) + slider.setValue(int(float(default_option)*multiplier)) slider_label = QtWidgets.QLabel(f"{slider.value()/multiplier}", self) From 380b07becc230e6335dee0e7b0d4983236faaa2a Mon Sep 17 00:00:00 2001 From: KylieGong Date: Sat, 9 Sep 2023 01:16:42 -0400 Subject: [PATCH 4/5] makefile changes --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 8752b31..fc9a1f1 100644 --- a/Makefile +++ b/Makefile @@ -176,19 +176,19 @@ test4: ## test5: native pyqt, tkrun style test5: - python pyqt.py testfile.sh + python qtrun.py ./testfile.sh #bash format with more variables test6: - python pyqt.py testfile2.sh + python qtrun.py testfile2.sh #python format test7: - python pyqt.py testfile3.py + python qtrun.py testfile3.py #csh format test8: - python pyqt.py testfile4.csh + python qtrun.py testfile4.csh ## test7: qooey, athena style test7: From 5dddbefea26ba6210ca34d838c4ebb73167dc6fc Mon Sep 17 00:00:00 2001 From: KylieGong Date: Sat, 9 Sep 2023 01:29:15 -0400 Subject: [PATCH 5/5] added -d flag, --- qtrun.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/qtrun.py b/qtrun.py index d5c6312..5da601c 100755 --- a/qtrun.py +++ b/qtrun.py @@ -138,7 +138,6 @@ def createWidgetsFromGroups(self): group_type, group_name, options, default_option, help = group if group_type == "RADIO": - # print("radio button created") new_group = QtWidgets.QButtonGroup() self.radio_groups.append(new_group) group_layout = QtWidgets.QHBoxLayout() @@ -156,7 +155,6 @@ def createWidgetsFromGroups(self): self.pagelayout.addLayout(group_layout) elif group_type == "IFILE" or group_type == "OFILE" or group_type == "IDIR" or group_type == "ODIR": - print("browse files button created") group_layout = QtWidgets.QHBoxLayout() label = QtWidgets.QLabel(group_name+":") label.setToolTip(help) @@ -177,7 +175,6 @@ def createWidgetsFromGroups(self): self.pagelayout.addLayout(group_layout) elif group_type == "CHECK": - # print("checkbox created") group_layout = QtWidgets.QHBoxLayout() label = QtWidgets.QLabel(group_name+":") label.setToolTip(help) @@ -192,7 +189,6 @@ def createWidgetsFromGroups(self): self.pagelayout.addLayout(group_layout) elif group_type == "ENTRY": - # print("textbox created") group_layout = QtWidgets.QHBoxLayout() label = QtWidgets.QLabel(group_name+":") label.setToolTip(help) @@ -210,9 +206,7 @@ def createWidgetsFromGroups(self): group_layout.addWidget(label) options = ''.join(options) options = options.split(':') - print(default_option) - # print("slider created") #creates a horizontal decimal slider decimals = len(str(options[2]).split('.')[1]) if '.' in str(options[2]) else 0 multiplier = 10**decimals @@ -240,6 +234,9 @@ def createWidgetsFromGroups(self): separator.setFixedHeight(1) # Set a fixed height for the separator self.pagelayout.addWidget(separator) + if args.debug: + print(f"{group_name} created as {group_type}") + def update_label(self): for slider, label, multiplier in self.sliders: label.setText(f"{slider.value()/multiplier}") @@ -336,8 +333,11 @@ def parsefile(file): return groups, filetype 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('-d', '--debug', action='store_true', help='Enable debug mode') + args = parser.parse_args() groups, filetype = parsefile(args.input_file)