From 0a8a0e3c53485db20a10f9454c37c7d4acdb7608 Mon Sep 17 00:00:00 2001 From: Ian Jauslin Date: Wed, 21 Feb 2024 16:00:15 -0500 Subject: [PATCH] Save shape and zoom level to conf --- src/painter.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/painter.py b/src/painter.py index b38050f..71fffa4 100644 --- a/src/painter.py +++ b/src/painter.py @@ -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: