I have a canvas located in a Sub window of my main application:
.dsm.nb.mdlbuild.canvas
additionally I have the following (one of several) proc helping me letting the user move stuff around on the canvas:
proc grab { xx yy } {
global currentx currenty
set currentx $xx
set currenty $yy
}
I use this binding:
.dsm.nb.mdlbuild.canvas bind $tagtomove <Button-1> {grab %x %y }
PROBLEM:
When the user closes the window (.dsm) the canvas gets distroyed to, but the binding seems to 'survive'.
When the user then subsequentually clicks somwhere he gets the error:
wrong args: should be "grab xx yy"
This because xx and yy is empty i suppose because the canvas is gone together with the parrent window...
I have tried to set the binding to nothing after the .dsm window is destroyed:
.dsm.nb.mdlbuild.canvas bind $tagtomove <Button-1> { }
and to use the "break" command, but with no success.
.dsm.nb.mdlbuild.canvas bind $tagtomove <Button-1> break
How can i remove the binding uppon closing the window (.dsm) in which the canvas is located so that this error does dissapear?
The problem is most likely that you used the name of a standard Tk command for your proc. The
grabcommand is called from different places in the Tk library, but not always matching the number of arguments of your proc. This would cause the error. You can check this by dumping the value of $errorInfo after you received the error message.So, just rename your proc to something other than
grab(or any other built-in command).