From e98f3582a84a4bbfec1eaed3855d5ca72174be77 Mon Sep 17 00:00:00 2001 From: duguxy Date: Sat, 15 Aug 2015 17:12:00 +0800 Subject: [PATCH 1/5] Fix: flowchart saveFile and loadFile in python3 --- pyqtgraph/flowchart/Flowchart.py | 8 ++++---- pyqtgraph/flowchart/Node.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pyqtgraph/flowchart/Flowchart.py b/pyqtgraph/flowchart/Flowchart.py index 17e2bde4..53731df0 100644 --- a/pyqtgraph/flowchart/Flowchart.py +++ b/pyqtgraph/flowchart/Flowchart.py @@ -514,7 +514,6 @@ class Flowchart(Node): return ## NOTE: was previously using a real widget for the file dialog's parent, but this caused weird mouse event bugs.. #fileName = QtGui.QFileDialog.getOpenFileName(None, "Load Flowchart..", startDir, "Flowchart (*.fc)") - fileName = unicode(fileName) state = configfile.readConfigFile(fileName) self.restoreState(state, clear=True) self.viewBox.autoRange() @@ -535,7 +534,8 @@ class Flowchart(Node): self.fileDialog.fileSelected.connect(self.saveFile) return #fileName = QtGui.QFileDialog.getSaveFileName(None, "Save Flowchart..", startDir, "Flowchart (*.fc)") - fileName = unicode(fileName) + if not fileName.endswith('.fc'): + fileName += '.fc' configfile.writeConfigFile(self.saveState(), fileName) self.sigFileSaved.emit(fileName) @@ -660,7 +660,7 @@ class FlowchartCtrlWidget(QtGui.QWidget): #self.setCurrentFile(newFile) def fileSaved(self, fileName): - self.setCurrentFile(unicode(fileName)) + self.setCurrentFile(fileName) self.ui.saveBtn.success("Saved.") def saveClicked(self): @@ -689,7 +689,7 @@ class FlowchartCtrlWidget(QtGui.QWidget): #self.setCurrentFile(newFile) def setCurrentFile(self, fileName): - self.currentFileName = unicode(fileName) + self.currentFileName = fileName if fileName is None: self.ui.fileNameLabel.setText("[ new ]") else: diff --git a/pyqtgraph/flowchart/Node.py b/pyqtgraph/flowchart/Node.py index fc7b04d3..9399fe2e 100644 --- a/pyqtgraph/flowchart/Node.py +++ b/pyqtgraph/flowchart/Node.py @@ -374,7 +374,7 @@ class Node(QtCore.QObject): pos = self.graphicsItem().pos() state = {'pos': (pos.x(), pos.y()), 'bypass': self.isBypassed()} termsEditable = self._allowAddInput | self._allowAddOutput - for term in self._inputs.values() + self._outputs.values(): + for term in list(self._inputs.values()) + list(self._outputs.values()): termsEditable |= term._renamable | term._removable | term._multiable if termsEditable: state['terminals'] = self.saveTerminals() From eb55e439a350473d250bc0a3180f57b008889d0f Mon Sep 17 00:00:00 2001 From: duguxy Date: Fri, 18 Sep 2015 11:49:04 +0800 Subject: [PATCH 2/5] Fix flowchat save load support --- pyqtgraph/flowchart/Flowchart.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pyqtgraph/flowchart/Flowchart.py b/pyqtgraph/flowchart/Flowchart.py index 53731df0..c57503f3 100644 --- a/pyqtgraph/flowchart/Flowchart.py +++ b/pyqtgraph/flowchart/Flowchart.py @@ -24,6 +24,7 @@ from .. import configfile as configfile from .. import dockarea as dockarea from . import FlowchartGraphicsView from .. import functions as fn +from ..python2_3 import asUnicode def strDict(d): return dict([(str(k), v) for k, v in d.items()]) @@ -660,7 +661,7 @@ class FlowchartCtrlWidget(QtGui.QWidget): #self.setCurrentFile(newFile) def fileSaved(self, fileName): - self.setCurrentFile(fileName) + self.setCurrentFile(asUnicode(fileName)) self.ui.saveBtn.success("Saved.") def saveClicked(self): @@ -689,7 +690,7 @@ class FlowchartCtrlWidget(QtGui.QWidget): #self.setCurrentFile(newFile) def setCurrentFile(self, fileName): - self.currentFileName = fileName + self.currentFileName = asUnicode(fileName) if fileName is None: self.ui.fileNameLabel.setText("[ new ]") else: From 9fa0d0e7244a4f60685e523bb986befe0c5c876c Mon Sep 17 00:00:00 2001 From: duguxy Date: Fri, 18 Sep 2015 19:53:09 +0800 Subject: [PATCH 3/5] Fix flowchart s&l on python2 --- pyqtgraph/flowchart/Flowchart.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyqtgraph/flowchart/Flowchart.py b/pyqtgraph/flowchart/Flowchart.py index c57503f3..2149a58a 100644 --- a/pyqtgraph/flowchart/Flowchart.py +++ b/pyqtgraph/flowchart/Flowchart.py @@ -515,6 +515,7 @@ class Flowchart(Node): return ## NOTE: was previously using a real widget for the file dialog's parent, but this caused weird mouse event bugs.. #fileName = QtGui.QFileDialog.getOpenFileName(None, "Load Flowchart..", startDir, "Flowchart (*.fc)") + fileName = asUnicode(fileName) state = configfile.readConfigFile(fileName) self.restoreState(state, clear=True) self.viewBox.autoRange() @@ -537,6 +538,7 @@ class Flowchart(Node): #fileName = QtGui.QFileDialog.getSaveFileName(None, "Save Flowchart..", startDir, "Flowchart (*.fc)") if not fileName.endswith('.fc'): fileName += '.fc' + fileName = asUnicode(fileName) configfile.writeConfigFile(self.saveState(), fileName) self.sigFileSaved.emit(fileName) From fd134f77c6fde72df39a14820482f182e899fdc0 Mon Sep 17 00:00:00 2001 From: Kenneth Lyons Date: Thu, 23 May 2019 17:53:42 -0700 Subject: [PATCH 4/5] Only append .fc file extension if not added in the file dialog. --- pyqtgraph/flowchart/Flowchart.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pyqtgraph/flowchart/Flowchart.py b/pyqtgraph/flowchart/Flowchart.py index 6a486232..f28ebc3b 100644 --- a/pyqtgraph/flowchart/Flowchart.py +++ b/pyqtgraph/flowchart/Flowchart.py @@ -525,7 +525,12 @@ class Flowchart(Node): self.restoreState(state, clear=True) self.viewBox.autoRange() self.sigFileLoaded.emit(fileName) - + + def saveFileSelected(self, fileName): + if not fileName.endswith('.fc'): + fileName += '.fc' + self.saveFile(fileName=fileName) + def saveFile(self, fileName=None, startDir=None, suggestedFileName='flowchart.fc'): """Save this flowchart to a .fc file """ @@ -537,11 +542,8 @@ class Flowchart(Node): self.fileDialog = FileDialog(None, "Save Flowchart..", startDir, "Flowchart (*.fc)") self.fileDialog.setAcceptMode(QtGui.QFileDialog.AcceptSave) self.fileDialog.show() - self.fileDialog.fileSelected.connect(self.saveFile) + self.fileDialog.fileSelected.connect(self.saveFileSelected) return - fileName = unicode(fileName) - if not fileName.endswith('.fc'): - fileName += '.fc' fileName = asUnicode(fileName) configfile.writeConfigFile(self.saveState(), fileName) self.sigFileSaved.emit(fileName) From ffd1624cb9b980abcced959e9c722e23e7ff04e8 Mon Sep 17 00:00:00 2001 From: Kenneth Lyons Date: Thu, 23 May 2019 19:02:56 -0700 Subject: [PATCH 5/5] Use defaultSuffix for smarter file extension handling. --- pyqtgraph/flowchart/Flowchart.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pyqtgraph/flowchart/Flowchart.py b/pyqtgraph/flowchart/Flowchart.py index f28ebc3b..ae03d4c2 100644 --- a/pyqtgraph/flowchart/Flowchart.py +++ b/pyqtgraph/flowchart/Flowchart.py @@ -526,11 +526,6 @@ class Flowchart(Node): self.viewBox.autoRange() self.sigFileLoaded.emit(fileName) - def saveFileSelected(self, fileName): - if not fileName.endswith('.fc'): - fileName += '.fc' - self.saveFile(fileName=fileName) - def saveFile(self, fileName=None, startDir=None, suggestedFileName='flowchart.fc'): """Save this flowchart to a .fc file """ @@ -540,9 +535,10 @@ class Flowchart(Node): if startDir is None: startDir = '.' self.fileDialog = FileDialog(None, "Save Flowchart..", startDir, "Flowchart (*.fc)") + self.fileDialog.setDefaultSuffix("fc") self.fileDialog.setAcceptMode(QtGui.QFileDialog.AcceptSave) self.fileDialog.show() - self.fileDialog.fileSelected.connect(self.saveFileSelected) + self.fileDialog.fileSelected.connect(self.saveFile) return fileName = asUnicode(fileName) configfile.writeConfigFile(self.saveState(), fileName)