next & previous file cycling implemented

This commit is contained in:
Markus Rosenstihl 2014-04-14 14:14:51 +02:00
parent eca637c35a
commit f70538567b

25
QDS.py
View File

@ -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])