def OnTBSave(self, event):
if self.data is None:
wx.MessageBox('Please record a spectrum first!', 'Save Spectrum', wx.OK | wx.ICON_INFORMATION)
return
if self.running:
rng = True
self.OnTBStart()
else:
rng = False
dlg = wx.FileDialog(None, "Save Spectrum", os.getcwd(), "", "*.*", wx.SAVE)
if dlg.ShowModal() == wx.ID_OK:
filename = dlg.GetPath()
# set new working directory
directory = os.path.split(filename)
if not os.path.isdir(filename):
os.chdir(directory[0])
# save file
np.savetxt(filename, np.transpose(np.array([self.wlAxis, self.data])))
# add to plot window
self.addLine(self.wlAxis, self.data)
dlg.Destroy()
if rng:
self.OnTBStart()
评论列表
文章目录