Skip to content Skip to sidebar Skip to footer

Unable To Unbind A Function Using Tkinter

I am working with Tkinter in Python 3.5 and I encounter a weird problem. I used the tkinterbook about events and bindings to write this simple example: from tkinter import * root

Solution 1:

The second argument to unbind is a 'funcid', not a function. help(root.unbind) returns

unbind(sequence, funcid=None) method of tkinter.Tk instance. Unbind for this widget for event SEQUENCE the function identified with FUNCID.

Many tk functions return tk object ids that can be arguments for other funtions, and bind is one of them.

>>>i = root.bind('<Button-1>', int)>>>i
'1733092354312int'
>>>root.unbind('<Button-1>', i)  # Specific binding removed.

Buried in the output from help(root.bind) is this: "Bind will return an identifier to allow deletion of the bound function with unbind without memory leak."

Post a Comment for "Unable To Unbind A Function Using Tkinter"