Deleting and changing a tkinter event binding

后端 未结 3 694
滥情空心
滥情空心 2020-12-05 18:23

How do i stop an event from being processed or switch what function is called for it?

Revised Code:

from Tkinter import *

class GUI         


        
3条回答
  •  星月不相逢
    2020-12-05 19:09

    You can simply just call bind() again with the new function for the event. Since you are not making use of the third parameter, add, in bind() this will just overwrite whatever is already there. By default this parameter is '' but it also accepts "+", which will add a callback to the callbacks already triggered by that event.

    If you start using that optional argument however you will need to use the unbind() function to remove individual callbacks. When you call bind() a funcid is returned. You can pass this funcid as the second parameter to unbind().

    Example:

    self.btn_funcid = self.DrawArea.bind("

提交回复
热议问题