def _export(self): import os.path files = [] fd = QtGui.QFileDialog() filters = ['IV data (*.iv *.xy *.cur *.fsm)', 'All Files (*)'] filename = str( fd.getSaveFileName(self, caption='Save IV data', directory=os.path.expanduser('~/'), filter=';;'.join(filters), selectedFilter=filters[0])) if filename: plots = self.plots labels = self.legend_labels if len(labels) < len(plots): labels += range(len(labels), len(plots)) for i, curve in enumerate(plots): basename, ext = os.path.splitext(filename) fname = basename + str(labels[i]) + ext with open(fname, 'w') as f: f.write('# {}\n'.format(labels[-1])) x, y = plots[i][0].get_data() for j in range(len(x)): f.write('{:20.6f} {:20.6f}\n'.format(x[j], y[j])) # append on success files.append(fname) return files
def _save(self): import os.path fd = QtGui.QFileDialog() filters = [ 'Images (*.png *.jpg)', 'Vector Graphics (*.ps *.svg)', 'Portable Document Format (*.pdf)', 'All Files (*)' ] filename = str( fd.getSaveFileName(self, caption='Save graph', directory=os.path.expanduser('~/'), filter=';;'.join(filters), selectedFilter=filters[0])) if filename: return self.save(filename)