Tk Source Code

View Ticket
Login
Ticket UUID: 1867834
Title: ttk Toolbutton has wrong default anchor
Type: Bug Version: 8.6.18, 9.0.5, 9.1.0
Submitter: boakley Created on: 2008-01-09 18:19:27
Subsystem: 88. Themed Tk Assigned To: jenglish
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2026-10-03 10:59:17
Resolution: Fixed Closed By: nemethi
    Closed on: 2026-10-03 10:59:17
Description:
Create two buttons like this:

package require Tk
ttk::button .a \
    -text "Hello" \
    -width 10 \
    -style Toolbutton
ttk::button .b \
    -text "World" \
    -width 10 
pack .a .b

On my windows XP machine the text of .a is left-
justified but the text of .b is centered.

The bug seems to be that the default anchor of the 
Toolbutton style is left when it should be center. 
I can fix this in my code with:

ttk::style configure Toolbutton -anchor center

I think the default for the Toolbutton should be
centered, shouldn't it?
User Comments: nemethi (claiming to be Csaba Nemethi) added on 2026-10-03 10:59:17:

Serhiy, many thanks for fixing this very long-standing bug! Merged into main, core-9-0-branch, and core-8-6-branch by commits [cc851a9f], [dd13e37a], and [3b8f72ca].


serhiy.storchaka added on 2026-09-30 14:12:13:

Still present in 9.1. Toolbutton is a separate style, and ttk style settings are not inherited across themes: every theme sets -anchor center for TButton, but only clam and aqua do so for Toolbutton, so in the default, alt, classic, winnative and vista themes the text falls back to the element default "w". Multi-line text is also left-justified within the button in all themes, while native Windows buttons and the classic Tk button center each line.

Proposed fix in branch toolbutton-center: -anchor center for Toolbutton in the default, alt, classic, winnative and vista themes, and -justify center in all themes. Test ttk-17.1. Tested on Linux/X11 and Windows 11.