澳门正规赌博十大网站-澳门游戏网站
做最好的网站

Mouse button differentiation: Mouse click

from Tkinter import *

class MouseDetails( Frame ):
   def __init__( self ):
      Frame.__init__( self )
      self.pack( expand = YES, fill = BOTH )
      self.master.title( 'Mouse clicks and buttons' )
      self.master.geometry( '350x150' )

      self.mousePosition = StringVar()
      positionLabel = Label( self,
         textvariable = self.mousePosition )
      self.mousePosition.set( 'Mouse not clicked' )
      positionLabel.pack( side = BOTTOM )

      self.bind( '<Button-1>', self.leftClick )

   def leftClick( self, event ):
      self.showPosition( event.x, event.y )
      self.master.title( 'Clicked with left mouse button' )

   def showPosition( self, x, y ):
      self.mousePosition.set( 'Pressed at [ '   str( x )   ', '  
         str( y )   ' ]' )     

def main():
   MouseDetails().mainloop()

if __name__ == '__main__':
   main()

本文由澳门正规赌博十大网站发布于澳门游戏网站,转载请注明出处:Mouse button differentiation: Mouse click