Save shape and zoom level to conf
This commit is contained in:
		| @@ -463,6 +463,14 @@ class Painter(Widget): | |||||||
|     # write configuration to file |     # write configuration to file | ||||||
|     def write(self,file): |     def write(self,file): | ||||||
|         ff=open(file,"w") |         ff=open(file,"w") | ||||||
|  |         # save state (particle shape, zoom, lattice) | ||||||
|  |         if self.shape==Cross: | ||||||
|  |             ff.write("%shape=cross\n") | ||||||
|  |         else: | ||||||
|  |             ff.write("%shape=disk\n") | ||||||
|  |         ff.write("%zoom={:1.1f}\n".format(self.base_size/50)) | ||||||
|  |         if self.lattice != None: | ||||||
|  |             ff.write("%lattice="+self.lattice.type+':'+str(self.lattice.spacing)+"\n") | ||||||
|         for particle in self.particles: |         for particle in self.particles: | ||||||
|             if type(particle)==Cross: |             if type(particle)==Cross: | ||||||
|                 ff.write("{:d};".format(CROSS_INDEX)) |                 ff.write("{:d};".format(CROSS_INDEX)) | ||||||
| @@ -502,6 +510,15 @@ class Painter(Widget): | |||||||
|             if len(line)==0: |             if len(line)==0: | ||||||
|                 continue |                 continue | ||||||
|  |  | ||||||
|  |             # read options | ||||||
|  |             if line[0]=='%': | ||||||
|  |                 [key,val]=line[1:].split('=',1) | ||||||
|  |                 if key=="shape": | ||||||
|  |                     self.app.command_prompt.run_set_shape(["set","shape",val]) | ||||||
|  |                 elif key=="zoom": | ||||||
|  |                     self.app.command_prompt.run_set_zoom(["set","zoom",val]) | ||||||
|  |                 continue | ||||||
|  |  | ||||||
|             entries=line.split(";") |             entries=line.split(";") | ||||||
|             # skip line if improperly formatted |             # skip line if improperly formatted | ||||||
|             if len(entries)>3: |             if len(entries)>3: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user