diff --git a/saenopy/gui/code/gui_code.py b/saenopy/gui/code/gui_code.py index 4bfcc533..7e72c16f 100644 --- a/saenopy/gui/code/gui_code.py +++ b/saenopy/gui/code/gui_code.py @@ -103,7 +103,7 @@ def update_console(self, open_script): self.console.setText(open_script.console) def load(self): - new_path = QtWidgets.QFileDialog.getOpenFileName(None, "Open Script", os.getcwd(), "Python File (*.py)") + new_path = QtWidgets.QFileDialog.getOpenFileName(None, "Open Script", os.getcwd(), "Python File (*.py)")[0] if new_path: self.do_load(new_path) diff --git a/saenopy/gui/common/BatchEvaluateBase.py b/saenopy/gui/common/BatchEvaluateBase.py index 3bd69b74..f2d33ff9 100644 --- a/saenopy/gui/common/BatchEvaluateBase.py +++ b/saenopy/gui/common/BatchEvaluateBase.py @@ -238,7 +238,7 @@ def generate_code(self): return except IndexError: return - new_path = QtWidgets.QFileDialog.getSaveFileName(None, "Save Session as Script", os.getcwd(), "Python File (*.py)") + new_path = QtWidgets.QFileDialog.getSaveFileName(None, "Save Session as Script", os.getcwd(), "Python File (*.py)")[0] if new_path: # ensure filename ends in .py if not new_path.endswith(".py"): diff --git a/saenopy/gui/common/PlottingWindowBase.py b/saenopy/gui/common/PlottingWindowBase.py index 97110d4d..9546b1a1 100644 --- a/saenopy/gui/common/PlottingWindowBase.py +++ b/saenopy/gui/common/PlottingWindowBase.py @@ -164,7 +164,7 @@ def __init__(self, parent=None, batch_evluate_instance=None): def save(self, filename=None): if filename is None: - filename = QtWidgets.QFileDialog.getSaveFileName(None, "Save Session", os.getcwd(), "JSON File (*.json)") + filename = QtWidgets.QFileDialog.getSaveFileName(None, "Save Session", os.getcwd(), "JSON File (*.json)")[0] if filename: if not filename.endswith(".json"): filename += ".json" @@ -179,7 +179,7 @@ def save(self, filename=None): def load(self, filename=None): if filename is None: - filename = QtWidgets.QFileDialog.getOpenFileName(None, "Load Session", os.getcwd(), "JSON File (*.json)") + filename = QtWidgets.QFileDialog.getOpenFileName(None, "Load Session", os.getcwd(), "JSON File (*.json)")[0] if filename: with open(filename, "r") as fp: list_new = json.load(fp) diff --git a/saenopy/gui/common/QtShortCuts.py b/saenopy/gui/common/QtShortCuts.py index c454870a..482eccaf 100644 --- a/saenopy/gui/common/QtShortCuts.py +++ b/saenopy/gui/common/QtShortCuts.py @@ -461,7 +461,6 @@ def value(self): class QInputChoice(QInput): - valueChanged = QtCore.Signal(str) def __init__(self, layout=None, name=None, value=None, values=None, value_names=None, reference_by_index=False, **kwargs): # initialize the super widget @@ -612,15 +611,15 @@ def _openDialog(self): # open an new files if not self.existing: if "PYCHARM_HOSTED" in os.environ: - filename = QtWidgets.QFileDialog.getSaveFileName(None, self.dialog_title, self.last_folder, self.file_type, options=QtWidgets.QFileDialog.DontUseNativeDialog) + filename = QtWidgets.QFileDialog.getSaveFileName(None, self.dialog_title, self.last_folder, self.file_type, options=QtWidgets.QFileDialog.DontUseNativeDialog)[0] else: - filename = QtWidgets.QFileDialog.getSaveFileName(None, self.dialog_title, self.last_folder, self.file_type) + filename = QtWidgets.QFileDialog.getSaveFileName(None, self.dialog_title, self.last_folder, self.file_type)[0] # or choose an existing file else: if "PYCHARM_HOSTED" in os.environ: - filename = QtWidgets.QFileDialog.getOpenFileName(None, self.dialog_title, self.last_folder, self.file_type, options=QtWidgets.QFileDialog.DontUseNativeDialog) + filename = QtWidgets.QFileDialog.getOpenFileName(None, self.dialog_title, self.last_folder, self.file_type, options=QtWidgets.QFileDialog.DontUseNativeDialog)[0] else: - filename = QtWidgets.QFileDialog.getOpenFileName(None, self.dialog_title, self.last_folder, self.file_type) + filename = QtWidgets.QFileDialog.getOpenFileName(None, self.dialog_title, self.last_folder, self.file_type)[0] # get the string if isinstance(filename, tuple): # Qt5 @@ -916,7 +915,7 @@ def AddQSaveFileChoose(layout, text, value=None, dialog_title="Choose File", fil lineEdit.setEnabled(False) def OpenDialog(): - srcpath = QtWidgets.QFileDialog.getSaveFileName(None, dialog_title, os.getcwd(), file_type) + srcpath = QtWidgets.QFileDialog.getSaveFileName(None, dialog_title, os.getcwd(), file_type)[0] if isinstance(srcpath, tuple): srcpath = srcpath[0] else: @@ -949,7 +948,7 @@ def AddQOpenFileChoose(layout, text, value=None, dialog_title="Choose File", fil lineEdit.setEnabled(False) def OpenDialog(): - srcpath = QtWidgets.QFileDialog.getOpenFileName(None, dialog_title, os.getcwd(), file_type) + srcpath = QtWidgets.QFileDialog.getOpenFileName(None, dialog_title, os.getcwd(), file_type)[0] if isinstance(srcpath, tuple): srcpath = srcpath[0] else: diff --git a/saenopy/gui/common/gui_classes.py b/saenopy/gui/common/gui_classes.py index 516a8d2c..5c1c213e 100644 --- a/saenopy/gui/common/gui_classes.py +++ b/saenopy/gui/common/gui_classes.py @@ -590,18 +590,3 @@ def set_result(self, result): self.thread.quit() self.worker.deleteLater() self.finished.emit() - - -def wrap_string(func): - def call(*args, **kwargs): - new_path = func(*args, **kwargs) - if new_path: - if isinstance(new_path, tuple): - new_path = new_path[0] - else: - new_path = str(new_path) - return new_path - return call - -QtWidgets.QFileDialog.getSaveFileName = wrap_string(QtWidgets.QFileDialog.getSaveFileName) -QtWidgets.QFileDialog.getOpenFileName = wrap_string(QtWidgets.QFileDialog.getOpenFileName) \ No newline at end of file diff --git a/saenopy/gui/common/stack_selector.py b/saenopy/gui/common/stack_selector.py index cb856245..4d7d836d 100644 --- a/saenopy/gui/common/stack_selector.py +++ b/saenopy/gui/common/stack_selector.py @@ -49,7 +49,7 @@ def __init__(self, layout, name, partner=None, use_time=False): layout.addWidget(self) def export(self): - new_path = QtWidgets.QFileDialog.getSaveFileName(None, "Save Images", os.getcwd()) + new_path = QtWidgets.QFileDialog.getSaveFileName(None, "Save Images", os.getcwd())[0] # if we got one, set it if new_path: if isinstance(new_path, tuple): diff --git a/saenopy/gui/material_fit/gui_fit.py b/saenopy/gui/material_fit/gui_fit.py index 7c35860d..e46c6af0 100644 --- a/saenopy/gui/material_fit/gui_fit.py +++ b/saenopy/gui/material_fit/gui_fit.py @@ -298,7 +298,7 @@ def set(params, keys=keys): self.canvas.draw() def add_measurement(self): - new_path = QtWidgets.QFileDialog.getOpenFileName(None, "Load Measurement", os.getcwd(), "Text File (*.txt);; CSV File (*.csv)") + new_path = QtWidgets.QFileDialog.getOpenFileName(None, "Load Measurement", os.getcwd(), "Text File (*.txt);; CSV File (*.csv)")[0] if new_path: self.add_file(new_path) diff --git a/saenopy/gui/solver/modules/TabResultView.py b/saenopy/gui/solver/modules/TabResultView.py index 01a87276..77741b67 100644 --- a/saenopy/gui/solver/modules/TabResultView.py +++ b/saenopy/gui/solver/modules/TabResultView.py @@ -218,7 +218,7 @@ def replot(self): plotter.render() def saveScreenshot(self): - new_path = QtWidgets.QFileDialog.getSaveFileName(self, "Save Image", os.getcwd(), "Image Files (*.jpg, *.png)") + new_path = QtWidgets.QFileDialog.getSaveFileName(self, "Save Image", os.getcwd(), "Image Files (*.jpg, *.png)")[0] # if we got one, set it if new_path: imageio.imsave(new_path, self.plotter.image) diff --git a/saenopy/gui/solver/modules/TabStackDisplay.py b/saenopy/gui/solver/modules/TabStackDisplay.py index 75e658f8..963eadc7 100644 --- a/saenopy/gui/solver/modules/TabStackDisplay.py +++ b/saenopy/gui/solver/modules/TabStackDisplay.py @@ -149,7 +149,7 @@ def check_available(self, result: Result) -> bool: def export(self): if self.result is None: return - new_path = QtWidgets.QFileDialog.getSaveFileName(None, "Save Images", os.getcwd()) + new_path = QtWidgets.QFileDialog.getSaveFileName(None, "Save Images", os.getcwd())[0] # if we got one, set it if new_path: new_path = new_path.strip(".gif").strip("_relaxed.tif").strip("_deformed.tif") diff --git a/saenopy/gui/solver/modules/VTK_Toolbar.py b/saenopy/gui/solver/modules/VTK_Toolbar.py index b1799cca..8a6c7605 100644 --- a/saenopy/gui/solver/modules/VTK_Toolbar.py +++ b/saenopy/gui/solver/modules/VTK_Toolbar.py @@ -183,7 +183,7 @@ def __init__(self, plotter: BasePlotter, update_display, scalbar_type="deformati self.button.clicked.connect(lambda x: self.plotter.isometric_view()) def save(): - new_path = QtWidgets.QFileDialog.getSaveFileName(None, "Save Images", os.getcwd()) + new_path = QtWidgets.QFileDialog.getSaveFileName(None, "Save Images", os.getcwd())[0] # if we got one, set it if new_path: print(new_path) diff --git a/saenopy/gui/solver/modules/exporter/Exporter.py b/saenopy/gui/solver/modules/exporter/Exporter.py index f461327a..c48e78be 100644 --- a/saenopy/gui/solver/modules/exporter/Exporter.py +++ b/saenopy/gui/solver/modules/exporter/Exporter.py @@ -639,7 +639,7 @@ def hide_stack_image(self): self.z_slider.setEnabled(isActive) def save_parameters(self): - new_path = QtWidgets.QFileDialog.getSaveFileName(None, "Save Parameters", os.getcwd(), "JSON File (*.json)") + new_path = QtWidgets.QFileDialog.getSaveFileName(None, "Save Parameters", os.getcwd(), "JSON File (*.json)")[0] if new_path: if not new_path.endswith(".json"): new_path += ".json" @@ -647,7 +647,7 @@ def save_parameters(self): json.dump(self.get_parameters(), fp, indent=2) def load_parameters(self): - new_path = QtWidgets.QFileDialog.getOpenFileName(None, "Load Parameters", os.getcwd(), "JSON File (*.json)") + new_path = QtWidgets.QFileDialog.getOpenFileName(None, "Load Parameters", os.getcwd(), "JSON File (*.json)")[0] if new_path: try: with open(new_path, "r") as fp: diff --git a/saenopy/gui/spheroid/modules/LookupTable.py b/saenopy/gui/spheroid/modules/LookupTable.py index 791ad731..0e534052 100644 --- a/saenopy/gui/spheroid/modules/LookupTable.py +++ b/saenopy/gui/spheroid/modules/LookupTable.py @@ -287,7 +287,7 @@ class SelectLookup(QtWidgets.QDialog): def loadExisting(self): last_folder = settings.value("batch", "batch/lookuptable_path") - filename = QtWidgets.QFileDialog.getOpenFileName(None, "Open Lookup Table", last_folder, "Numpy Lookup Table (*.npy);; Pickle Lookup Table (*.pkl)") + filename = QtWidgets.QFileDialog.getOpenFileName(None, "Open Lookup Table", last_folder, "Numpy Lookup Table (*.npy);; Pickle Lookup Table (*.pkl)")[0] filename = filename[0] if isinstance(filename, tuple) else str(filename) if filename is not None else None if filename == "": diff --git a/saenopy/gui/tfm2d/modules/BatchEvaluate.py b/saenopy/gui/tfm2d/modules/BatchEvaluate.py index 0f23a877..77fe33b5 100644 --- a/saenopy/gui/tfm2d/modules/BatchEvaluate.py +++ b/saenopy/gui/tfm2d/modules/BatchEvaluate.py @@ -81,7 +81,7 @@ def tab_changed(x): def generate_data(self): new_path = QtWidgets.QFileDialog.getSaveFileName(None, "Save Data CSV", os.getcwd(), - "Comma Separated File (*.csv)") + "Comma Separated File (*.csv)")[0] if not new_path: return None # ensure filename ends in .py