diff --git a/WireChem.py b/WireChem.py index 8dbde6e..1c45905 100644 --- a/WireChem.py +++ b/WireChem.py @@ -151,7 +151,7 @@ def savelevel(w,l): #initialisation du jeu def init(): - global worlds,debug + global worlds,debug,level verifyhome() read("dbdata") read(gethome()+"/dbdata") @@ -167,8 +167,8 @@ def init(): debug=False worlds={} +world=level=0 init() -print debug ''' *********************************************************************************************** ''' ''' Classes graphiques ''' @@ -260,52 +260,53 @@ class abutton(object): del self self=None + + def launch(self,state): + name=self.name.split('_') + if len(name)>1 and hasattr(self.window, "on_mouse_"+state['event']+"_"+name[0]) and callable(eval("self.window.on_mouse_"+state['event']+"_"+name[0])): + eval("self.window.on_mouse_"+state['event']+"_"+name[0]+"("+str(name[1])+","+str(state)+")") + if hasattr(self.window, "on_mouse_"+state['event']+"_"+self.name) and callable(eval("self.window.on_mouse_"+state['event']+"_"+self.name)): + if self.typeof=='multicon': + self.index+=1 + if self.index>=len(self.content): + self.index=0 + self.update(0) + eval("self.window.on_mouse_"+state['event']+"_"+self.name+"("+str(state)+")") + def on_mouse_press(self, x, y, button, modifiers): if x>self.x and y>self.y and x=len(self.content): - self.index=0 - self.update(0) - eval("self.window.on_mouse_press_"+self.name+"("+str(state)+")") + state={'x':x,'y':y, 'dx':0, 'dy':0, 'buttons':button, 'modifiers':modifiers, 'event': 'press'} + self.launch(state) def on_mouse_release(self, x, y, button, modifiers): if x>self.x and y>self.y and xself.x and y>self.y and xself.x and y>self.y and xself.x and y>self.y and xself.x and y>self.y and xself.x and y>self.y and x