Tk Source Code

View Ticket
Login
Ticket UUID: 1439266
Title: -values and -from/to inconsistent
Type: Bug Version: obsolete: 8.4.12
Submitter: usus Created on: 2006-02-26 21:40:36
Subsystem: 17. [spinbox] Assigned To: jan.nijtmans
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2026-10-01 20:57:07
Resolution: Fixed Closed By: jan.nijtmans
    Closed on: 2026-10-01 20:57:07
Description:
Options -from/to and -values behave differently.
Example:

# Initialisation of variables at the top
set months {January February March April May June July
August September October November December}
foreach {day mon year} [clock format [clock seconds]
-format "%e %B %Y"] break
# ......
# part of the GUI (date chooser)
spinbox    .f1.f11.dat.day -from 1 -to 31 \
           -width 2 -state readonly -textvariable day
spinbox    .f1.f11.dat.mon -values $months \
           -width 9 -state readonly -textvariable mon
spinbox    .f1.f11.dat.year -from 1980 -to 2036 \
           -width 4 -state readonly -textvariable year

After packing and displaying it, it shows 25. January
2006 (tested 25. February 2006) as the current date.
Day and year, configured with from/to work correctly,
mon configured with -values insists on the first value
of the list. When I set the month after the definition
of the spinbox, everything is ok.

The different behaviour of -from/to and -values on the
other hand is at least unexpected and confusing.
Does it mean I should initialize the textvariable
_always_ after the instantiation, because the behaviour
in the -from/to case might change at any time without
notice?

In my eyes this is a bug of spinbox, at least an
inconsistency.
User Comments: jan.nijtmans added on 2026-10-01 20:57:07:

Fixed [9929acd1332bd2da|here], backported to core-9-0-branch and core-8-6-branch


serhiy.storchaka added on 2026-09-23 12:14:31:

Confirmed, and still there. ConfigureEntry() in generic/tkEntry.c sets the value from -textvariable first, and then the -values branch replaced it unconditionally with the first element, while the -from/-to branch right below only moves a value which lies outside the range — hence -from 1 -to 31 keeps 25, but -values $months turned February into January. Now the current value is kept when it is one of -values, and the first element is used otherwise, as before. Branch spinbox-values-keep-value, tests spinbox-5.13 and spinbox-5.14.

It is a behaviour change, so probably main only.


hobbs added on 2006-03-31 14:56:28:
Logged In: YES 
user_id=72656

See also 841280.