def onClickSave(self, event): # wxGlade: MainFrame.<event_handler> # Get file information fileTypes = 'Sample databases (*.db)|*.db', 'Matlab matrices (*.mat)|*.mat' dialog = wx.FileDialog(self, 'Save', style=wx.SAVE, wildcard='|'.join(fileTypes)) if dialog.ShowModal() != wx.ID_OK: return targetPath = dialog.GetPath() fileType = dialog.GetFilterIndex() dialog.Destroy() # If the user wants to save the data as a database, save it if fileType == 0: sample_store.save(self.samples, store.replaceFileExtension(targetPath, 'db')) # If the user wants to save the data in Matlab format, save it else: sample_store.saveForMatlab(self.samples, store.replaceFileExtension(targetPath, 'mat'))
def onClickSave(self, event): # wxGlade: MainFrame.<event_handler> # Get file information dialog = wx.FileDialog(self, 'Save', style=wx.SAVE, wildcard='Connection maps (*.map)|*.map') if dialog.ShowModal() != wx.ID_OK: return connectionMapPath = store.replaceFileExtension(dialog.GetPath(), 'map') connectionCSVWriter = csv.writer(open(store.replaceFileExtension(connectionMapPath, 'csv'), 'w')) dialog.Destroy() # Get connections connections = [] for rowIndex in xrange(self.grid.GetNumberRows()): row = [] for columnIndex in xrange(self.grid.GetNumberCols()): value = self.grid.GetCellValue(rowIndex, columnIndex) row.append(value) if value: connections.append((rowIndex, columnIndex)) connectionCSVWriter.writerow(row) # Save open(connectionMapPath, 'wt').write(classifier_cnn.makeLushMatrix(connections))