返回顶部

收藏

Mouse action: drag

更多
from Tkinter import *

def showAllEvent(event):
    print event
    for attr in dir(event): 
        print attr, '=>', getattr(event, attr) 

def showPosEvent(event):
    print 'Widget=%s X=%s Y=%s' % (event.widget, event.x, event.y)

def onLeftDrag(event):
    print 'Got left mouse button drag:',
    showPosEvent(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('<B1-Motion>', onLeftDrag)  

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

标签:Python,Event

收藏

0人收藏

支持

0

反对

0