[New-bugs-announce] [issue42328] ttk style.map function incorrectly handles the default state for element options.

Pat Thoyts report at bugs.python.org
Wed Nov 11 19:27:54 EST 2020


New submission from Pat Thoyts <patthoyts at users.sourceforge.net>:

When cloning a ttk style it is useful to copy an existing style and make changes. We can copy the configuration and layout using:

    style.layout('Custom.TEntry', **style.layout('TEntry'))
    style.configure('Custom.TEntry', **style.configure('TEntry))

However, doing this with style.map can result in an exception. An example of this occurs for any style that has a defined default state in the map eg the TNotebook.Tab in the clam theme:

    >>> style.map('TNotebook.Tab','background')
    [('selected', '#dcdad5'), ('#bab5ab',)]

However, calling Tk directly:

    >>> style.tk.call(style._name,"map","TNotebook.Tab","-background")
    (<StateSpec object: 'selected'>, '#dcdad5', <StateSpec object: ''>, '#bab5ab')

The second pair is defining the default state ('') to use color #bab5ab but this is being mangled by the code that converts this into pythons response.

The culprit is ttk._list_from_statespec which treats the statespec with the empty string as None and drops it and then returns the value in place of the state and then puts in an empty value.

----------
components: Tkinter
messages: 380798
nosy: patthoyts
priority: normal
severity: normal
status: open
title: ttk style.map function incorrectly handles the default state for element options.
type: behavior
versions: Python 3.8

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


More information about the New-bugs-announce mailing list