开发者

Multiple Functions Bound to a Single Widget

开发者 https://www.devze.com 2023-04-03 21:09 出处:网络
I\'m binding multiple functions to a single widget using 开发者_运维知识库the same sequence (in this case the \'<Button>\' sequence) in Tkinter. To do this I\'m using the add argument. Is it pos

I'm binding multiple functions to a single widget using 开发者_运维知识库the same sequence (in this case the '<Button>' sequence) in Tkinter. To do this I'm using the add argument. Is it possible to get all the functions bound to a particular sequence?

snippet :

wid.bind('<Button>', func0)
wid.bind('<Button>', func1, add=True)


If I understand the question correctly, you can create one callback function:

def cb(event):
    func0()
    func1()
    # ...

wid.bind('<Button>', cb)

Also, you can replace add=True with '+':

wid.bind('<Button>, func1, '+')
0

精彩评论

暂无评论...
验证码 换一张
取 消