Mouse events on a frame : Mouse Action : Event PYTHON examples


PYTHON examples » Event » Mouse Action »

 

Mouse events on a frame


Mouse events on a frame: Mouse clicked, position

from Tkinter import *

class MouseLocationFrame ):
   def __init__self ):
      Frame.__init__self )
      self.packexpand = YES, fill = BOTH )
      self.master.title"Demonstrating Mouse Events" )
      self.master.geometry(  "275x100" )
      
      self.mousePosition = StringVar() # displays mouse position
      self.mousePosition.set"Mouse outside window" )
      self.positionLabel = Labelself,
         textvariable = self.mousePosition )
      self.positionLabel.packside = BOTTOM )

      # bind mouse events to window
      self.bind"<Button-1>", self.buttonPressed )

   def buttonPressedself, event ):
      self.mousePosition.set"Pressed at [ " + strevent.x 
         ", " + strevent.y " ]" )

def main():
   MouseLocation().mainloop()

if __name__ == "__main__":
   main()

           
       



Leave a Comment / Note


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


PYTHON examples

 Navioo Event
» Mouse Action