Tk Source Code

View Ticket
Login
Ticket UUID: 2262543
Title: Scale widget unexpectedly fires command callback
Type: Bug Version: obsolete: 8.4.19
Submitter: nobody Created on: 2008-11-11 14:00:20
Subsystem: 15. [scale] Assigned To: fvogel
Priority: 6 Severity: Minor
Status: Closed Last Modified: 2016-03-07 21:03:16
Resolution: Fixed Closed By: fvogel
    Closed on: 2016-03-07 21:03:16
Description:
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
User Comments: fvogel added on 2016-03-07 21:03:16:
Merged in trunk and core-8-6-branch.

fvogel added on 2016-02-24 17:36:08:
Fix proposed in branch bug-2262543fff.

Several tests were added:

- scale-20.[4678]: non regression tests (these passed without the fix)

- scale-20.[1235]: pass with the fix

[email protected] added on 2008-11-11 21:00:20:

File Added - 300992: test_scalefire.py

Attachments: