[New-bugs-announce] [issue33373] ttk modules Label class does not respect background config option

C.D. MacEachern report at bugs.python.org
Fri Apr 27 10:28:23 EDT 2018


New submission from C.D. MacEachern <craigmaceachern at fastmail.com>:

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 (http://www.tcl.tk/man/tcl8.6/TkCmd/ttk_label.htm#M6) 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:

https://stackoverflow.com/questions/23750141/tkinter-ttk-widgets-ignoring-background-color/50064376#50064376

----------
components: Tkinter
messages: 315844
nosy: cmaceachern
priority: normal
severity: normal
status: open
title: ttk modules Label class does not respect background config option
type: behavior
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33373>
_______________________________________


More information about the New-bugs-announce mailing list