def open(self, dirname, filename): if not os.path.exists(os.path.join(dirname, filename)): wx.MessageBox('File not found', 'Error', wx.OK | wx.ICON_ERROR) self.filename = filename self.dirname = dirname self.status.set_general("Opening: {0}".format(filename)) self.scanInfo, spectrum = open_plot(dirname, filename) if len(spectrum) > 0: self.spectrum.clear() self.scanInfo.setToSettings(self.settings) self.spectrum = spectrum self.isSaved = True self.set_controls() self.set_control_state(True) self.graph.get_axes().clear() self.update_plot(True) self.status.set_general("Finished") self.settings.fileHistory.AddFileToHistory(os.path.join(dirname, filename)) else: self.status.set_general("Open failed")
def on_load_plot(self, event): dlg = wx.FileDialog(self, "Open a scan", self.dirname, self.filename, File.RFS, wx.OPEN) if dlg.ShowModal() == wx.ID_OK: self.dirname = dlg.GetDirectory() self.filename = dlg.GetFilename() _start, _stop, spectrum = open_plot(self.dirname, self.filename) if event.EventObject == self.buttonPlot1: self.textPlot1.SetLabel(self.filename) self.graph.set_spectrum1(spectrum) else: self.textPlot2.SetLabel(self.filename) self.graph.set_spectrum2(spectrum) dlg.Destroy()