Tk Source Code

View Ticket
Login
Ticket UUID: 1dde2144bdcc5a93f8724fc1b1b85b19114e42c0
Title: ttk style configure overwrites Tk option add Button but not Label
Type: Bug Version: 8.6.6
Submitter: anonymous Created on: 2016-09-29 21:54:21
Subsystem: 88. Themed Tk Assigned To: nobody
Priority: 5 Medium Severity: Minor
Status: Open Last Modified: 2017-04-04 20:36:28
Resolution: None Closed By: nobody
    Closed on:
Description:
Note, the original report was written for Python at http://bugs.python.org/issue28313 . TCL code below.

The following code will result in a small label and a big button:

from tkinter import *
from tkinter.ttk import *

root = Tk()

root.option_add("*Font", "sans-serif 12")

s = Style()
s.configure('TButton', font=('courier', 40))
s.configure('TLabel', font=('courier', 40))

Label(root, text="lbl").pack()
Button(root, text="bttn").pack()

root.mainloop()


It seems to me that both should have the same style. Removing the root.option_add line fixes it of course but this is a stripped-down example and in other cases it might be needed.

option add *Font {sans-serif 12}
ttk::style configure TButton -font {courier 40}
ttk::style configure TLabel -font {courier 40}
ttk::label .label -text lbl
pack configure .label
ttk::button .button -text bttn
pack configure .button