Save color in conf
This commit is contained in:
parent
ff11c1ce84
commit
5384d9a964
@ -475,6 +475,7 @@ class Painter(Widget):
|
||||
else:
|
||||
ff.write("%shape=disk\n")
|
||||
ff.write("%zoom={:1.1f}\n".format(self.base_size/50))
|
||||
ff.write("%color={:d},{:d},{:d}\n".format(self.color[0],self.color[1],self.color[2]))
|
||||
if self.lattice != None:
|
||||
ff.write("%lattice="+self.lattice.type+':'+str(self.lattice.spacing)+"\n")
|
||||
for particle in self.particles:
|
||||
@ -518,19 +519,28 @@ class Painter(Widget):
|
||||
|
||||
# read options
|
||||
if line[0]=='%':
|
||||
# ignore empty line
|
||||
if len(line)==1:
|
||||
continue
|
||||
[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])
|
||||
elif key=="color":
|
||||
color_str=val.split(',')
|
||||
try:
|
||||
self.set_color((float(color_str[0]),float(color_str[1]),float(color_str[2])))
|
||||
except:
|
||||
print("warning: ignoring line "+str(i)+" in file '"+file+"': color '"+color_str+"' cannot be read",file=sys.stderr)
|
||||
continue
|
||||
|
||||
entries=line.split(";")
|
||||
# skip line if improperly formatted
|
||||
if len(entries)>3:
|
||||
print("warning: ignoring line "+str(i)+" in file '"+file+"': more than three ';' spearated entries in '"+line+"'",file=sys.stderr)
|
||||
print("warning: ignoring line "+str(i)+" in file '"+file+"': more than three ';' separated entries in '"+line+"'",file=sys.stderr)
|
||||
if len(entries)<2:
|
||||
print("warning: ignoring line "+str(i)+" in file '"+file+"': fewer than two ';' spearated entries in '"+line+"'",file=sys.stderr)
|
||||
print("warning: ignoring line "+str(i)+" in file '"+file+"': fewer than two ';' separated entries in '"+line+"'",file=sys.stderr)
|
||||
continue
|
||||
|
||||
# position
|
||||
|
Loading…
Reference in New Issue
Block a user