#2541 Scale widget unexpectedly fires command callback

obsolete: 8.4.19
open
Jeffrey Hobbs
5
2008-11-11
2008-11-11
Anonymous
No

The Tk scale widget (used through the Python/Tkinter interface) fires its command unexpectedly when it is initialized with a value. This behavior is different then say, a checkbox, which can be initialized with a value without triggering the command callback. I'm attaching a script which shows this behavior.

scale1 is initialized with a value through the variable option. The command callback for scale1 fires unexpectedly when the mainloop starts. I say unexpectedly, because the value of the scale is never changed from its initial value (at least from the user/coders point of view).

scale2 is initialized without a command callback. The command callback is registered AFTER the value is changed, yet the callback still fires upon entering mainloop.

Both of these behaviors strike me as unexpected, and contrary to how the command callback is typically used for other widgets. Also in the test script are two checkbuttons that are initialized in similar fashion to the scale widgets above, and you can see that their command callbacks do not fire.

This issue was discussed on the Tkinter mailing list: http://mail.python.org/pipermail/tkinter-discuss/2008-November/001714.html and there is additional info in Guilherme Polo's helpful replies.

Guilherme also supplied this minimal tcl sample of the behavior as well, which I don't understand enough to explain:

scale .s -command {puts}
pack .s

Thanks -

Dave Giesen

Discussion

  • Python/Tkinter test showing the unexpected scale behavior

     
    Attachments