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) return self.filename = os.path.splitext(filename)[0] self.settings.dirScans = dirname self.status.set_general("Opening: {0}".format(filename)) self.scanInfo, spectrum, location = open_plot(dirname, filename) if len(spectrum) > 0: self.scanInfo.setToSettings(self.settings) self.spectrum = spectrum self.location = location self.__saved(True) self.__set_controls() self.__set_control_state(True) self.__set_plot(spectrum, self.settings.annotate) self.graph.scale_plot(True) self.status.set_general("Finished") self.settings.fileHistory.AddFileToHistory(os.path.join(dirname, filename)) else: self.status.set_general("Open failed")
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) return self.__on_new(None) self.graph.get_canvas().draw() self.filename = os.path.splitext(filename)[0] self.settings.dirScans = dirname self.status.set_general("Opening: {}".format(filename)) self.scanInfo, spectrum, location = open_plot(dirname, filename) if len(spectrum) > 0: self.scanInfo.set_to_settings(self.settings) self.spectrum = spectrum self.locations.clear() self.locations.update(location) self.__saved(True) self.__set_controls() self.__set_control_state(True) self.__set_plot(spectrum, self.settings.annotate) self.graph.scale_plot(True) self.status.set_general("Finished") self.settings.fileHistory.AddFileToHistory(os.path.join(dirname, filename)) else: self.status.set_general("Open failed", level=Log.ERROR)
def __merge(self, dirname, filename): if not os.path.exists(os.path.join(dirname, filename)): wx.MessageBox('File not found', 'Error', wx.OK | wx.ICON_ERROR) return self.filename = os.path.splitext(filename)[0] self.settings.dirScans = dirname self.status.set_general("Merging: {}".format(filename)) _scanInfo, spectrum, locations = open_plot(dirname, filename) if len(spectrum) > 0: spectrum.update(self.spectrum) locations.update(self.locations) self.spectrum.clear() self.locations.clear() self.spectrum.update(OrderedDict(sorted(spectrum.items()))) self.locations.update(OrderedDict(sorted(locations.items()))) self.__set_plot(self.spectrum, self.settings.annotate) self.graph.scale_plot(True) self.status.set_general("Finished") self.settings.fileHistory.AddFileToHistory(os.path.join(dirname, filename)) else: self.status.set_general("Merge failed", level=Log.ERROR)
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) return self.__on_new(None) self.graph.get_canvas().draw() self.filename = os.path.splitext(filename)[0] self.settings.dirScans = dirname self.status.set_general("Opening: {}".format(filename)) self.scanInfo, spectrum, location = open_plot(dirname, filename) if len(spectrum) > 0: self.scanInfo.set_to_settings(self.settings) self.spectrum = spectrum self.locations.clear() self.locations.update(location) self.__saved(True) self.__set_controls() self.__set_control_state(True) self.__set_plot(spectrum, self.settings.annotate) self.graph.scale_plot(True) self.status.set_general("Finished") self.settings.fileHistory.AddFileToHistory( os.path.join(dirname, filename)) else: self.status.set_general("Open failed", level=Log.ERROR)
def __merge(self, dirname, filename): if not os.path.exists(os.path.join(dirname, filename)): wx.MessageBox('File not found', 'Error', wx.OK | wx.ICON_ERROR) return self.filename = os.path.splitext(filename)[0] self.settings.dirScans = dirname self.status.set_general("Merging: {}".format(filename)) _scanInfo, spectrum, locations = open_plot(dirname, filename) if len(spectrum) > 0: spectrum.update(self.spectrum) locations.update(self.locations) self.spectrum.clear() self.locations.clear() self.spectrum.update(OrderedDict(sorted(spectrum.items()))) self.locations.update(OrderedDict(sorted(locations.items()))) self.__set_plot(self.spectrum, self.settings.annotate) self.graph.scale_plot(True) self.status.set_general("Finished") self.settings.fileHistory.AddFileToHistory( os.path.join(dirname, filename)) else: self.status.set_general("Merge failed", level=Log.ERROR)
def __on_load_plot(self, event): dlg = wx.FileDialog(self, "Open a scan", self.dirname, self.filename, File.get_type_filters(File.Types.SAVE), wx.OPEN) if dlg.ShowModal() == wx.ID_OK: self.dirname = dlg.GetDirectory() self.filename = dlg.GetFilename() _scanInfo, spectrum, _location = 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()
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() _scanInfo, 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()
def __open(self, dirname, filename): _info, spectrum, _locs = open_plot(dirname, filename) self.directory = dirname self.__plot(sort_spectrum(spectrum)) vv.title(filename)