comparison pyink/MBScene.py @ 1147:5cfa73d7e80f

Add the Run button to simulate the animation
author wycc
date Fri, 24 Dec 2010 15:00:28 +0800
parents e14ec6d1a661
children 153a87b4edb7
comparison
equal deleted inserted replaced
1146:e14ec6d1a661 1147:5cfa73d7e80f
134 self.last_select = None 134 self.last_select = None
135 self.lockui=False 135 self.lockui=False
136 self.tween=None 136 self.tween=None
137 self.document = None 137 self.document = None
138 self.dom = None 138 self.dom = None
139 self.framerate=12
140 self.maxframe=0
139 pass 141 pass
140 142
141 def show_selection(self,w,obj): 143 def show_selection(self,w,obj):
142 objs = self.desktop.selection.list() 144 objs = self.desktop.selection.list()
143 try: 145 try:
197 start = int(s.getAttribute("start")) 199 start = int(s.getAttribute("start"))
198 except: 200 except:
199 traceback.print_exc() 201 traceback.print_exc()
200 continue 202 continue
201 try: 203 try:
202 end = s.getAttribute("end") 204 end = int(s.getAttribute("end"))
203 if end == None: 205 if end == None:
204 end = start 206 end = start
205 pass 207 pass
206 except: 208 except:
207 end = start 209 end = start
208 pass 210 pass
211 if end > self.maxframe:
212 self.maxframe = end
209 try: 213 try:
210 typ = s.getAttribute('type') 214 typ = s.getAttribute('type')
211 if typ == None: 215 if typ == None:
212 typ = 'normal' 216 typ = 'normal'
213 except: 217 except:
794 hbox.pack_start(self.nameEditor,expand=False,fill=False) 798 hbox.pack_start(self.nameEditor,expand=False,fill=False)
795 self.editDone = gtk.Button('Set') 799 self.editDone = gtk.Button('Set')
796 hbox.pack_start(self.editDone,expand=False,fill=False) 800 hbox.pack_start(self.editDone,expand=False,fill=False)
797 self.editDone.connect('clicked', self.changeObjectLabel) 801 self.editDone.connect('clicked', self.changeObjectLabel)
798 802
799 def doRun(self): 803 def doRun(self,arg):
800 """ 804 """
801 Execute the current animation till the last frame. 805 Execute the current animation till the last frame.
802 """ 806 """
807 if self.btnRun.get_label() == "Run":
808 self.btnRun.set_label("Stop")
809 self.last_update = glib.timeout_add(1000/self.framerate,self.doRunNext)
810 else:
811 self.btnRun.set_label("Run")
812 glib.source_remove(self.last_update)
813
814 def doRunNext(self):
815 if self.current >= self.maxframe:
816 self.current = 0
817 print self.current,self.maxframe
818 self.setCurrentScene(self.current+1)
819 self.last_update = glib.timeout_add(1000/self.framerate,self.doRunNext)
803 820
804 821
805 def addButtons(self,hbox): 822 def addButtons(self,hbox):
806 #btn = gtk.Button('Edit') 823 #btn = gtk.Button('Edit')
807 #btn.connect('clicked', self.doEditScene) 824 #btn.connect('clicked', self.doEditScene)
818 btn=gtk.Button('Duplicate Key') 835 btn=gtk.Button('Duplicate Key')
819 btn.connect('clicked', self.doDuplicateKeyScene) 836 btn.connect('clicked', self.doDuplicateKeyScene)
820 hbox.pack_start(btn,expand=False,fill=False) 837 hbox.pack_start(btn,expand=False,fill=False)
821 btn=gtk.Button('Run') 838 btn=gtk.Button('Run')
822 btn.connect('clicked', self.doRun) 839 btn.connect('clicked', self.doRun)
840 self.btnRun = btn
823 hbox.pack_start(btn,expand=False,fill=False) 841 hbox.pack_start(btn,expand=False,fill=False)
824 self.addNameEditor(hbox) 842 self.addNameEditor(hbox)
825 self.addTweenTypeSelector(hbox) 843 self.addTweenTypeSelector(hbox)
826 844
827 pass 845 pass