返回顶部

收藏

Mouse events on a frame: Mouse left

更多
from Tkinter import *

class MouseLocation( Frame ):
   def __init__( self ):
      Frame.__init__( self )
      self.pack( expand = 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 = Label( self,
         textvariable = self.mousePosition )
      self.positionLabel.pack( side = BOTTOM )

      self.bind( '<Leave>', self.exitedWindow )

   def exitedWindow( self, event ):
      self.mousePosition.set( 'Mouse outside window' )

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

if __name__ == '__main__':
   main()

标签:Python,Event

收藏

0人收藏

支持

0

反对

0