Mouse events on a frame: Mouse clicked, position,eventsclicked,from Tkinter
Mouse events on a frame: Mouse clicked, position,eventsclicked,from Tkinter
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 ) # bind mouse events to window self.bind( '<Button-1>', self.buttonPressed ) def buttonPressed( self, event ): self.mousePosition.set( 'Pressed at [ ' + str( event.x ) + ', ' + str( event.y ) + ' ]' )def main(): MouseLocation().mainloop()if __name__ == '__main__': main()
- Read a file line by line,fileline,file = open(
- Built-in function len(): get the length of a list,buil
- Different way to output string: print and sys.stdout.wri
- Print module infomation,moduleinfomation,//File: modu
- split and join,splitjoin,s = 'this
- Handling Exceptions,handlingexceptions,# It is poss
热门文章:
相关内容
- Read a file line by line,fileline,file = open(
- Built-in function len(): get the length of a list,built-inlen,a = [
- Different way to output string: print and sys.stdout.write,,X = 99p
- Print module infomation,moduleinfomation,//File: modu
- split and join,splitjoin,s = 'this
- Handling Exceptions,handlingexceptions,# It is poss
- Set font from Root component,fontcomponent,from Tkinter
- Math: abs and pow,mathabsandpow,import mathp
- Assigning Consecutive Values,,print range(
- String Simple Conversion:,simpleconversion,# The simple
评论关闭