petri_dish
diff scale.py @ 11:53672899af16
all initial parameters are read
author | Yashina Ksenia <ksenia_yashina@kodomo.fbb.msu.ru> |
---|---|
date | Mon, 13 Dec 2010 21:26:28 +0300 |
parents | 50d862c2c691 |
children | 7408ce97c651 f350d610c986 |
line diff
1.1 --- a/scale.py Wed Dec 08 00:30:58 2010 +0300 1.2 +++ b/scale.py Mon Dec 13 21:26:28 2010 +0300 1.3 @@ -1,16 +1,62 @@ 1.4 from Tkinter import * 1.5 +import Bacteria 1.6 +import Petri 1.7 + 1.8 +class IF: 1.9 + def __init__(self,delay=10,diam=300,num=1,env=1,reprod_a=False,reprod_s=False,life=1): 1.10 + self.delay=delay 1.11 + self.diam=diam 1.12 + self.num=num 1.13 + self.env=env 1.14 + self.reprod_s=reprod_s 1.15 + self.reprod_a=reprod_a 1.16 + self.life=life 1.17 + 1.18 + def __repr__(self): 1.19 + return "<%s,%s,%s,%s,%s,%s,%s>"%(self.delay,self.diam,self.num,\ 1.20 + self.env,self.reprod_a,\ 1.21 + self.reprod_s,self.life) 1.22 + #def mutate(): 1.23 + 1.24 + def sbmt(self): 1.25 + submit.config(text="Stop",command=self.stop) 1.26 + scl1.config(state=DISABLED) 1.27 + scl2.config(state=DISABLED) 1.28 + scl3.config(state=DISABLED) 1.29 + cb1.config(state=DISABLED) 1.30 + cb2.config(state=DISABLED) 1.31 + self.num=scl1.get() 1.32 + self.diam=scl2.get() 1.33 + self.life=scl3.get() 1.34 + c.config(height=self.diam+20,width=self.diam+20,bg="gray75") 1.35 + filler=c.create_rectangle(0,0,self.diam+22,self.diam+22,fill="lightgrey") 1.36 + c.grid(row=0,column=2,rowspan=6,padx=50,pady=10) 1.37 + dish=c.create_oval(10,10,self.diam+10,self.diam+10,fill="white") 1.38 + print self 1.39 + 1.40 + def stop(self): 1.41 + submit.config(text="Submit",command=self.sbmt) 1.42 + scl1.config(state=NORMAL) 1.43 + scl2.config(state=NORMAL) 1.44 + scl3.config(state=NORMAL) 1.45 + cb1.config(state=NORMAL) 1.46 + cb2.config(state=NORMAL) 1.47 + 1.48 + def new_reprod_a(self): 1.49 + self.reprod_a=not(self.reprod_a) 1.50 + return 1.51 + 1.52 + def new_reprod_s(self): 1.53 + self.reprod_s=not(self.reprod_s) 1.54 + return 1.55 + 1.56 + # def depict(self): 1.57 + # root.after(self.delay,intf.depict()) 1.58 + 1.59 root = Tk() 1.60 root.title("Interface") 1.61 - 1.62 -#def mutate(): 1.63 - 1.64 -def sbmt(): 1.65 - submit.config(state=DISABLED) 1.66 - scl1.config(state=DISABLED) 1.67 - scl2.config(state=DISABLED) 1.68 - scl3.config(state=DISABLED) 1.69 - cb1.config(state=DISABLED) 1.70 - cb2.config(state=DISABLED) 1.71 +intf=IF() 1.72 +c=Canvas() 1.73 1.74 init_frame=LabelFrame(root,text="Initial parameters") 1.75 init_frame.grid(padx=15,pady=10) 1.76 @@ -19,7 +65,7 @@ 1.77 scl1.grid(row=0, column=0,padx=10,pady=5) 1.78 lbl1 = Label(init_frame,text="number of cells",bg="white") 1.79 lbl1.grid(row=0,column=1,padx=10) 1.80 -scl2 = Scale(init_frame,orient=HORIZONTAL,length=100,from_=20,\ 1.81 +scl2 = Scale(init_frame,orient=HORIZONTAL,length=100,from_=100,\ 1.82 to=500,sliderlength=7,width=10) 1.83 scl2.grid(row=1, column=0,padx=10,pady=5) 1.84 lbl2 = Label(init_frame,text="diameter of Petri dish",bg="white") 1.85 @@ -32,15 +78,15 @@ 1.86 lbl_frame=LabelFrame(init_frame,text="Reproduction") 1.87 lbl_frame.grid(row=4,column=0,columnspan=2,padx=15,pady=10) 1.88 list=["Asexual","Sexual"] 1.89 -cb1 = Checkbutton(lbl_frame,text="Asexual") 1.90 +cb1 = Checkbutton(lbl_frame,text="Asexual",command=intf.new_reprod_a) 1.91 cb1.pack() 1.92 -cb2 = Checkbutton(lbl_frame,text="Sexual") 1.93 +cb2 = Checkbutton(lbl_frame,text="Sexual",command=intf.new_reprod_s) 1.94 cb2.pack() 1.95 1.96 -submit=Button(root,text="Submit",width=25,command=sbmt) 1.97 +submit=Button(root,text="Submit",width=25,command=intf.sbmt) 1.98 submit.grid(row=1,column=0,columnspan=2,pady=10) 1.99 1.100 -chng_frame=LabelFrame(root,text="Changable parameters") 1.101 +chng_frame=LabelFrame(root,text="Changeable parameters") 1.102 chng_frame.grid(padx=15,pady=10) 1.103 scl = Scale(chng_frame,orient=HORIZONTAL,length=100,from_=1,\ 1.104 to=100,sliderlength=7,width=10) 1.105 @@ -50,8 +96,6 @@ 1.106 btn = Button(chng_frame,text="Add mutation",width=25)#,command=mutate) 1.107 btn.grid(row=1,column=0,columnspan=2,pady=10) 1.108 1.109 -diam=400 1.110 -c=Canvas(height=diam+20,width=diam+20,relief=RIDGE) 1.111 -dish=c.create_oval(10,10,diam+10,diam+10,fill="white") 1.112 -c.grid(row=0,column=2,rowspan=6,padx=50,pady=10) 1.113 +#root.after(intf.delay,intf.depict()) 1.114 + 1.115 mainloop()