wx.PostEvent(self.frame, export_image(name=name, dest=dest))
- def help_txt(self):
- print '''
-TXT
-Saves the current curve as a text file
-Columns are, in order:
-X1 , Y1 , X2 , Y2 , X3 , Y3 ...
-
--------------
-Syntax: txt [filename] {plot to export}
- '''
- def do_txt(self,args):
-
- def transposed2(lists, defval=0):
- '''
- transposes a list of lists, i.e. from [[a,b,c],[x,y,z]] to [[a,x],[b,y],[c,z]] without losing
- elements
- (by Zoran Isailovski on the Python Cookbook online)
- '''
- if not lists: return []
- return map(lambda *row: [elem or defval for elem in row], *lists)
-
- whichplot=0
- args=args.split()
- if len(args)==0:
- filename=linp.safeinput('Filename?',[self.current.path+'.txt'])
- else:
- filename=linp.checkalphainput(args[0],self.current.path+'.txt',[])
- try:
- whichplot=int(args[1])
- except:
- pass
-
- try:
- outofplot=self.plots[whichplot].vectors
- except:
- print "Plot index out of range."
- return 0
-
- columns=[]
- for dataset in self.plots[whichplot].vectors:
- for i in range(0,len(dataset)):
- columns.append([])
- for value in dataset[i]:
- columns[-1].append(str(value))
-
- rows=transposed2(columns, 'nan')
- rows=[' , '.join(item) for item in rows]
- text='\n'.join(rows)
-
- txtfile=open(filename,'w+')
- #Save units of measure in header
- txtfile.write('X:'+self.plots[whichplot].units[0]+'\n')
- txtfile.write('Y:'+self.plots[whichplot].units[1]+'\n')
- txtfile.write(text)
- txtfile.close()
-
-
'''
def do_current(self,args):
print self.current.path
+
+
+ def help_txt(self):
+ print '''
+TXT
+Saves the current curve as a text file
+Columns are, in order:
+X1 , Y1 , X2 , Y2 , X3 , Y3 ...
+
+-------------
+Syntax: txt [filename] {plot to export}
+ '''
+ def do_txt(self,args):
+
+ def transposed2(lists, defval=0):
+ '''
+ transposes a list of lists, i.e. from [[a,b,c],[x,y,z]] to [[a,x],[b,y],[c,z]] without losing
+ elements
+ (by Zoran Isailovski on the Python Cookbook online)
+ '''
+ if not lists: return []
+ return map(lambda *row: [elem or defval for elem in row], *lists)
+
+ whichplot=0
+ args=args.split()
+ if len(args)==0:
+ filename=linp.safeinput('Filename?',[self.current.path+'.txt'])
+ else:
+ filename=linp.checkalphainput(args[0],self.current.path+'.txt',[])
+ try:
+ whichplot=int(args[1])
+ except:
+ pass
+
+ try:
+ outofplot=self.plots[whichplot].vectors
+ except:
+ print "Plot index out of range."
+ return 0
+
+ columns=[]
+ for dataset in self.plots[whichplot].vectors:
+ for i in range(0,len(dataset)):
+ columns.append([])
+ for value in dataset[i]:
+ columns[-1].append(str(value))
+
+ rows=transposed2(columns, 'nan')
+ rows=[' , '.join(item) for item in rows]
+ text='\n'.join(rows)
+
+ txtfile=open(filename,'w+')
+ #Save units of measure in header
+ txtfile.write('X:'+self.plots[whichplot].units[0]+'\n')
+ txtfile.write('Y:'+self.plots[whichplot].units[1]+'\n')
+ txtfile.write(text)
+ txtfile.close()