Mouse button differentiation : Mouse Action : Event PYTHON examples


PYTHON examples » Event » Mouse Action »

 

Mouse button differentiation


Mouse button differentiation: Right Button click

from Tkinter import *

class MouseDetailsFrame ):
   def __init__self ):
      Frame.__init__self )
      self.packexpand = YES, fill = BOTH )
      self.master.title"Mouse clicks and buttons" )
      self.master.geometry"350x150" )

      self.mousePosition = StringVar()
      positionLabel = Labelself,
         textvariable = self.mousePosition )
      self.mousePosition.set"Mouse not clicked" )
      positionLabel.packside = BOTTOM )

      self.bind"<Button-3>", self.rightClick )

   def rightClickself, event ):
      self.showPositionevent.x, event.y )
      self.master.title"Clicked with right mouse button" )

   def showPositionself, x, y ):
      self.mousePosition.set"Pressed at [ " + str", " +
         str" ]" )     

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

if __name__ == "__main__":
   main()

           
       



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo Event
» Mouse Action