From 49d19509bcac69b972c481abcba950f3ca6e4ade Mon Sep 17 00:00:00 2001 From: Le_dahut Date: Thu, 5 Jun 2014 16:03:33 +0200 Subject: [PATCH] =?UTF-8?q?-Ajout=20de=20la=20mobilit=C3=A9=20du=20fond=20?= =?UTF-8?q?-Tout=20les=20boutons=20passent=20en=20surbrillance=20lors=20du?= =?UTF-8?q?=20passage=20de=20la=20souris=20-Detection=20du=20clic=20sur=20?= =?UTF-8?q?les=20niveaux=20et=20coloration=20de=20ceux-ci=20au=20survol=20?= =?UTF-8?q?de=20la=20souris=20-Centralisation=20du=20lancement=20des=20?= =?UTF-8?q?=C3=A9v=C3=A8nements=20et=20gestion=20du=20regroupement=20des?= =?UTF-8?q?=20=C3=A9v=C3=A8nements?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WireChem.py | 122 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 80 insertions(+), 42 deletions(-) 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