Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset
Comments Off

Obtenir la position ‘x’ et ‘y’ de clique de la souris

 set, tkinter
{filelink=15673}

from Tkinter import *
 
class Position_Souris( Frame ):
   def __init__( self ):
      Frame.__init__( self )
      self.pack( expand = YES, fill = BOTH )
      self.master.title( "Evénement souris" )
      self.master.geometry( "350x100" )
 
      self.mousePosition = StringVar()
      positionLabel = Label( self,textvariable = self.mousePosition )
      self.mousePosition.set( "Cliquez quelque part qur la fenêtre" )
      positionLabel.pack( side = TOP)
 
      self.bind( "<Button-1>", self.click )
 
   def click( self, event ):
      self.clickPosition( event.x, event.y )
 
   def clickPosition( self, x, y ):
      self.mousePosition.set( "Souris Pressée à [ " + str( x ) + ", " +
         str( y ) + " ]" )     
 
def main():
   Position_Souris().mainloop()
 
if __name__ == "__main__":
   main()

Livres Sur ce Sujet

----------------------------------------------------------------------------

Comments are closed.