Display all attributes of an event : Event : Tkinker PYTHON TUTORIALS


PYTHON TUTORIALS » Tkinker » Event »

 

Display all attributes of an event


Display all attributes of an event
from Tkinter import *
     
def showPosEvent(event):
    print 'Widget=%s X=%s Y=%s' % (event.widget, event.x, event.y)
     
def showAllEvent(event):
    print event
    for attr in dir(event)
        print attr, '=>', getattr(event, attr
     
     
def onMiddleClick(event):
    print 'Got middle mouse button click:', 
    showPosEvent(event)
    showAllEvent(event)
     
tkroot = Tk()
labelfont = ('courier', 20'bold')                
widget = Label(tkroot, text='Hello bind world')
widget.config(bg='red', font=labelfont)            
widget.config(height=5, width=20)                  
widget.pack(expand=YES, fill=BOTH)

widget.bind('<Button-2>',  onMiddleClick)          

widget.focus()                                     
tkroot.title('Click Me')
tkroot.mainloop()



Leave a Comment / Note


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


PYTHON TUTORIALS

 Navioo Tkinker
» Event