Title: Tkinter ttk Label background ignored on MacOS
Type: behavior Stage: resolved
Components: macOS, Tkinter Versions: Python 3.8, Python 3.7, Python 3.6
Status: closed Resolution: third party
Dependencies: Superseder:
Assigned To: Nosy List: cmaceachern, ned.deily, ronaldoussoren, serhiy.storchaka, terry.reedy
Priority: normal Keywords:

Created on 2018-04-27 14:28 by cmaceachern, last changed 2018-04-29 04:18 by serhiy.storchaka. This issue is now closed.

Messages (3)
msg315844 - (view) Author: C.D. MacEachern (cmaceachern) Date: 2018-04-27 14:28
Python tkinter.ttk.Label instance is not respecting background configuration.

I'm running 3.6.5 64-bit python with Tk 8.6 on OS X 10.13.4.

Here is an output of an interactive session to demonstrate the steps. Notice that the ttk.Label keys() output shows that the ‘background’ config option is supported. Additionally, the ttk::label manual page ( shows that the ‘-background’ option is an available ‘widget-specific option’. 

[~/projects/parou/src (2.0)] $ python3
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 05:52:31)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter as tk
>>> import tkinter.ttk as ttk
>>> root = tk.Tk()
>>> tk_label = tk.Label(root)
>>> tk_label.keys()
['activebackground', 'activeforeground', 'anchor', 'background', 'bd', 'bg', 'bitmap', 'borderwidth', 'compound', 'cursor', 'disabledforeground', 'fg', 'font', 'foreground', 'height', 'highlightbackground', 'highlightcolor', 'highlightthickness', 'image', 'justify', 'padx', 'pady', 'relief', 'state', 'takefocus', 'text', 'textvariable', 'underline', 'width', 'wraplength']
>>> tk_label.config(text='Old style tkinter.Label instance', foreground='blue', background='red')
>>> tk_label.pack()
>>> new_ttk_label = ttk.Label(root)
>>> new_ttk_label.keys()
['background', 'foreground', 'font', 'borderwidth', 'relief', 'anchor', 'justify', 'wraplength', 'takefocus', 'text', 'textvariable', 'underline', 'width', 'image', 'compound', 'padding', 'state', 'cursor', 'style', 'class']
>>> new_ttk_label.config(text='New tkinter.ttk.Label instance', foreground='blue', background='blue')
>>> new_ttk_label.pack()
>>> tk_label.config('background')
('background', 'background', 'Background', <border object: 'White'>, 'red')
>>> new_ttk_label.config('background')
('background', 'frameColor', 'FrameColor', '', <border object: 'blue'>)
>>> new_ttk_label.config('foreground')
('foreground', 'textColor', 'TextColor', '', <color object: 'blue'>)
>>> root.mainloop()

I would expect the background to change colour on the ttk Label the same way it does when I change the background on the tkinter.Label instance.

It appears to not have worked as documented since 2014 for some, so my suggestion would be to remove 'background' as an option exposed in ttk.Label().keys().

Link to SO thread where it is discussed as well:
msg315858 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2018-04-27 21:47
ttk Label backgrounds work fine on Windows and, possibly, Linux (Serhiy?), and even, possibly with tcl/tk 8.6 on macOS (Ned?).  tk 8.6 for macOS has gotten several bug fixes.  C.D., please download and try out the 3.7.0b3 macOS installer.  It included and will install for Python's use the current tcl/tk 8.6.x bugfix release.

import tkinter as tk
from tkinter import ttk
r = tk.Tk()
l = ttk.Label(r, text='colored label', background='red')
r.mainloop()  # if not in IDLE

We obviously should not remove something that works as intended on some systems.
msg315880 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-04-29 04:18
ttk.Label is just a think wrapper around Tk's ttk::label. If there are problems with setting background on MacOS, it should be reported on the Tk bagtracker.
Date User Action Args
2018-04-29 04:18:18serhiy.storchakasetstatus: open -> closed
resolution: third party
messages: + msg315880

stage: resolved
2018-04-27 21:47:09terry.reedysettitle: ttk modules Label class does not respect background config option -> Tkinter ttk Label background ignored on MacOS
nosy: + terry.reedy, serhiy.storchaka, ned.deily, ronaldoussoren

messages: + msg315858

versions: + Python 3.7, Python 3.8
components: + macOS
2018-04-27 14:28:23cmaceacherncreate