Tk Source Code

View Ticket
Login
Ticket UUID: 3313032
Title: ttk::spinbox doesn't expand its height on Linux
Type: Bug Version: obsolete: 8.5.9, 8.6.18, 9.0.5, 9.1.0
Submitter: dunkfan Created on: 2011-06-07 09:59:40
Subsystem: 88. Themed Tk Assigned To: jenglish
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2026-10-01 17:25:47
Resolution: Fixed Closed By: nemethi
    Closed on: 2026-10-01 17:25:47
Description:
The height of the entry field in a spinbox widget remains constant even when it should grow to fill its available space.

package require Tk
ttk::frame .fm
ttk::spinbox .fm.sb
pack .fm.sb -fill both -expand 1
pack .fm -fill both -expand 1

#Other widgets, entry, spinbox, ttk::entry expand to fill the available vertical space. (Noticed on Linux)
User Comments: nemethi (claiming to be Csaba Nemethi) added on 2026-10-01 17:25:47:

Serhiy, many thanks for the fix! Merged into main, core-9-0-branch, and core-8-6-branch by commits [c548a23a], [ece6a4fe], and [0335f925].


serhiy.storchaka added on 2026-09-30 18:25:16:

The default TSpinbox layout, used by the default, alt, clam and winnative themes, did not stretch Spinbox.field vertically, so it kept its requested height at the top of the spinbox. The winnative theme is used on Windows with the Basic and High Contrast themes; the vista and classic themes have their own layouts in which the field fills the spinbox.

Just making the field fill the spinbox is not enough: the arrows must be adapted too. Toolkits differ here: Motif keeps the arrows at a fixed size, grouped in the middle, while the classic Tk spinbox, the native up-down control on Windows and Qt give each arrow half of the height.

Proposed fix in branch spinbox-fill-height: the field fills the whole height of the spinbox, and the text is centered in it. The arrows keep their size and are grouped in the middle in the default, alt and clam themes, as in Motif, and take half of the height each in the classic and winnative themes (and in the vista theme since [3301552]). Tests spinbox-6.1 to 6.4. Tested on Linux/X11 and Windows 11.

It is still an open question which themes should keep the fixed size of the arrows.


fvogel added on 2018-08-26 20:22:55:

Confirmed on Windows Vista.

Run the test script, then using the mouse enlarge the height of the toplevel window.

When using the normal standard usual Windows theme, the spinbox enlarges as expected.

When using the high contrast theme of the OS (through Ctrl+Shift+PtrScr), the spinbox does not enlarge. Running ttk::style configure TSpinbox -background red in addition shows the red background below the spinbox, meaning that in fact it enlarges partially (I guess some parts of the spinbox enlarge, some others do not).


dunkfan added on 2012-04-03 19:37:32:
Just noticed the same problem on Windows & when using Basic and High Contrast themes instead of the standard Windows7 Aero theme.