Save shape and zoom level to conf

This commit is contained in:
Ian Jauslin 2024-02-21 16:00:15 -05:00
parent b1d56fea04
commit 0a8a0e3c53
1 changed files with 17 additions and 0 deletions

View File

@ -463,6 +463,14 @@ class Painter(Widget):
# write configuration to file
def write(self,file):
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:
if type(particle)==Cross:
ff.write("{:d};".format(CROSS_INDEX))
@ -502,6 +510,15 @@ class Painter(Widget):
if len(line)==0:
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(";")
# skip line if improperly formatted
if len(entries)>3: