From f70538567b4e9b9da0876dc42047ec10519d7cf1 Mon Sep 17 00:00:00 2001 From: Markus Rosenstihl Date: Mon, 14 Apr 2014 14:14:51 +0200 Subject: [PATCH] next & previous file cycling implemented --- QDS.py | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/QDS.py b/QDS.py index 8a5e4eb..3c2b1f2 100755 --- a/QDS.py +++ b/QDS.py @@ -65,11 +65,16 @@ class AppWindow(QMainWindow): openFile.triggered.connect(self.getFileNames) fileMenu.addAction(openFile) - nextFile = QAction("&Next", self) - nextFile.setShortcut(QKeySequence.FindNext) + nextFile = QAction("Next", self) + nextFile.setShortcut(QKeySequence("Ctrl+k")) nextFile.triggered.connect(self.nextFile) fileMenu.addAction(nextFile) + previousFile = QAction("Previous", self) + previousFile.setShortcut(QKeySequence("Ctrl+j")) + previousFile.triggered.connect(self.previousFile) + fileMenu.addAction(previousFile) + saveFile = QAction("&Save Fit Result", self) @@ -460,6 +465,14 @@ class AppWindow(QMainWindow): path = unicode(self._file_paths[self._current_file_index]) self.openFile(path) + def previousFile(self): + if self._current_file_index == 0: # wrap around + self._current_file_index = len(self._file_paths) - 1 + else: + self._current_file_index -= 1 + path = unicode(self._file_paths[self._current_file_index]) + self.openFile(path) + def openFile(self,path): print "opening: %s"%path self.filepath=path @@ -471,7 +484,8 @@ class AppWindow(QMainWindow): Temp = None for line in open(path).readlines(): if re.search("Fixed", line) or re.search("Temp", line): - print "Found line with Fixed or Temp" + print "Found line containing 'Fixed' or 'Temp':" + print line Temp = float(re.search(numpat, line).group()) print "Temperature found in file:", Temp break @@ -504,14 +518,13 @@ class AppWindow(QMainWindow): # calculate parametrized curve self.data.set_fit(p0, funcs) - # replot data and fit, TODO: replot only if data changed + # replot data and fit, TODO: replot only if measurement data changed self.data.data_curve_real.setData(self.data.frequency, self.data.epsilon.real) self.data.data_curve_imag.setData(self.data.frequency, self.data.epsilon.imag) - if len(funcs)> 0: + if len(funcs) > 0: self.data.fitted_curve_real.setData(self.data.frequency_fit, self.data.epsilon_fit.real) self.data.fitted_curve_imag.setData(self.data.frequency_fit, self.data.epsilon_fit.imag) - else: self.data.fitted_curve_real.setData([np.nan],[np.nan]) self.data.fitted_curve_imag.setData([np.nan],[np.nan])