TkInter: understanding unbind function
Asked Answered
D

1

7

Does TkInter unbind function prevents the widget on which it is applied from binding further events to the widget ?

Clarification:

Let's say I bound events to a canvas earlier in a prgram:

 canvas.bind("<Button-1>",some_function)

Then at a certain point of the program, we no longer need those events:

 canvas.unbind("<Button-1>")

Can we later do something like this:

 canvas.bind("<Button-1>",OTHER_function)
Dateline answered 12/5, 2015 at 15:47 Comment(4)
My bad, I misread the question. Of course, this can be done. After unbinding a function from an event, you can then bind a function to the event.Germanism
It would be better to provide a minimal example of what you've tried and a clear description of the issue.Weirdie
@Weirdie this question does not need an example given its nature. I am asking about the effect of a method that is not mine but offered by a library, so any one who had experience with it could answer. No need for code.Dateline
The question in its current form is pointless - the obvious answer is "why don't you try it and see?" But then you commented "I have a real problem in binding an other event after unbinding" - presumably you have tried it, but failed to make it work, so I would suggest skipping the interim steps and asking the question you actually want answering!Weirdie
D
10

No, unbinding an event doesn't prevent further bindings on the widget. You can bind an event, unbind it, and then bind it again at a later date as often as you want.

Drought answered 12/5, 2015 at 16:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.