Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.cmm.msu.ru/hg/petri_dish/rev/f350d610c986
Дата изменения: Unknown
Дата индексирования: Tue Oct 2 17:27:36 2012
Кодировка:
petri_dish: f350d610c986

petri_dish

changeset 13:f350d610c986

added menu bar
author Yashina Ksenia <ksenia_yashina@kodomo.fbb.msu.ru>
date Tue, 14 Dec 2010 17:10:59 +0300
parents 53672899af16
children 05518686d7af
files scale.py
diffstat 1 files changed, 33 insertions(+), 5 deletions(-) [+]
line diff
     1.1 --- a/scale.py	Mon Dec 13 21:26:28 2010 +0300
     1.2 +++ b/scale.py	Tue Dec 14 17:10:59 2010 +0300
     1.3 @@ -2,7 +2,7 @@
     1.4  import Bacteria
     1.5  import Petri
     1.6  
     1.7 -class IF:
     1.8 +class IF(object):
     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 @@ -16,7 +16,8 @@
    1.13          return "<%s,%s,%s,%s,%s,%s,%s>"%(self.delay,self.diam,self.num,\
    1.14                                           self.env,self.reprod_a,\
    1.15                                           self.reprod_s,self.life)
    1.16 -    #def mutate():
    1.17 +    def mutate():
    1.18 +        pass
    1.19  
    1.20      def sbmt(self):
    1.21          submit.config(text="Stop",command=self.stop)
    1.22 @@ -49,15 +50,42 @@
    1.23      def new_reprod_s(self):
    1.24          self.reprod_s=not(self.reprod_s)
    1.25          return
    1.26 +
    1.27 +    def help(self):
    1.28 +        pass
    1.29 +
    1.30 +    def pause(self):
    1.31 +        pass
    1.32      
    1.33 -   # def depict(self):
    1.34 -      #  root.after(self.delay,intf.depict())
    1.35 +    def depict(self):
    1.36 +        pass
    1.37  
    1.38  root = Tk()
    1.39  root.title("Interface")
    1.40  intf=IF()
    1.41  c=Canvas()
    1.42  
    1.43 +menubar = Menu(root)
    1.44 +
    1.45 +# create a pulldown menu, and add it to the menu bar
    1.46 +controlsmenu = Menu(menubar, tearoff=0)
    1.47 +controlsmenu.add_command(label="Start", command=intf.sbmt)
    1.48 +controlsmenu.add_command(label="Stop", command=intf.stop)
    1.49 +controlsmenu.add_command(label="Add mutation", command=intf.mutate)
    1.50 +controlsmenu.add_separator()
    1.51 +controlsmenu.add_command(label="Exit", command=root.destroy)
    1.52 +#controlmenu.add_command(label="Pause", command=intf.pause)
    1.53 +menubar.add_cascade(label="Controls", menu=controlsmenu)
    1.54 +
    1.55 +helpmenu = Menu(menubar, tearoff=0)
    1.56 +helpmenu.add_command(label="About", command=intf.help)
    1.57 +menubar.add_cascade(label="Help", menu=helpmenu)
    1.58 +
    1.59 +# display the menu
    1.60 +root.config(menu=menubar)
    1.61 +
    1.62 +
    1.63 +
    1.64  init_frame=LabelFrame(root,text="Initial parameters")
    1.65  init_frame.grid(padx=15,pady=10)
    1.66  scl1 = Scale(init_frame,orient=HORIZONTAL,length=100,from_=1,\
    1.67 @@ -93,7 +121,7 @@
    1.68  scl.grid(row=0, column=0,padx=10,pady=5)
    1.69  lbl = Label(chng_frame,text="environment",bg="white")
    1.70  lbl.grid(row=0,column=1,padx=10)
    1.71 -btn = Button(chng_frame,text="Add mutation",width=25)#,command=mutate)
    1.72 +btn = Button(chng_frame,text="Add mutation",width=25,command=intf.mutate)
    1.73  btn.grid(row=1,column=0,columnspan=2,pady=10)
    1.74  
    1.75  #root.after(intf.delay,intf.depict())