saving removes bad characters

This commit is contained in:
Dominik Demuth 2023-01-26 19:30:39 +01:00
parent af313c7a58
commit 0eb0a4be77
3 changed files with 17 additions and 9 deletions

View File

@ -578,16 +578,16 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
if suffix == '.pdf': if suffix == '.pdf':
from ..io.exporters import PDFPrintExporter from ..io.exporters import PDFPrintExporter
PDFPrintExporter(self.graphic).export(outfile) PDFPrintExporter(self.graphic).export(str(outfile))
elif suffix == '.svg': elif suffix == '.svg':
from pyqtgraph.exporters import SVGExporter from pyqtgraph.exporters import SVGExporter
SVGExporter(self.scene).export(outfile) SVGExporter(self.scene).export(str(outfile))
else: else:
from pyqtgraph.exporters import ImageExporter from pyqtgraph.exporters import ImageExporter
ImageExporter(self.scene).export(outfile) ImageExporter(self.scene).export(str(outfile))
self.set_color(foreground=fg_color, background=bg_color) self.set_color(foreground=fg_color, background=bg_color)

View File

@ -114,7 +114,7 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
self.datawidget.management = self.management self.datawidget.management = self.management
self.integralwidget.management = self.management self.integralwidget.management = self.management
# self.drawingswidget.graphs = self.management.graphs self.drawingswidget.graphs = self.management.graphs
self.ac_group = QtWidgets.QActionGroup(self) self.ac_group = QtWidgets.QActionGroup(self)
self.ac_group.addAction(self.action_lm_fit) self.ac_group.addAction(self.action_lm_fit)
@ -126,8 +126,6 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
self.ac_group2.addAction(self.action_x_range) self.ac_group2.addAction(self.action_x_range)
self.ac_group2.addAction(self.action_custom_range) self.ac_group2.addAction(self.action_custom_range)
self.action_draw_object.setVisible(False)
def _init_signals(self): def _init_signals(self):
self.actionRedo = self.management.undostack.createRedoAction(self) self.actionRedo = self.management.undostack.createRedoAction(self)
icon = QtGui.QIcon.fromTheme("edit-redo") icon = QtGui.QIcon.fromTheme("edit-redo")
@ -268,6 +266,10 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
param_outfile = re.sub('[_\s-]?<label>[_\s-]?', '', savefile.stem) param_outfile = re.sub('[_\s-]?<label>[_\s-]?', '', savefile.stem)
bad_character = r'/*<>\|:"'
for c in bad_character:
param_outfile = param_outfile.replace(c, '')
if save_dialog.agr_cb.isChecked(): if save_dialog.agr_cb.isChecked():
self.current_graph_widget.export(savefile.with_name(param_outfile + '.agr')) self.current_graph_widget.export(savefile.with_name(param_outfile + '.agr'))
@ -598,8 +600,9 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
def _select_drawingswidget(self, onoff): def _select_drawingswidget(self, onoff):
if onoff: if onoff:
self.drawingswidget(self.management.graphs.list()) if self.drawingswidget.graphs is None:
self.drawingswidget.connected_figure = self.management.current_graph self.drawingswidget.graphs = self.management.graphs
self.drawingswidget.update_tree()
else: else:
self.drawingswidget.clear() self.drawingswidget.clear()

View File

@ -1116,7 +1116,12 @@ class UpperManagement(QtCore.QObject):
else: else:
real_outnames.append(full_name) real_outnames.append(full_name)
outpath_set = path.with_name(real_outnames[-1]+path.suffix) out_name = real_outnames[-1]
bad_character = r'/*<>\|:"'
for c in bad_character:
out_name = out_name.replace(c, '')
outpath_set = path.with_name(out_name+path.suffix)
data_i.save(outpath_set) data_i.save(outpath_set)