New submission from Pat Thoyts <[email protected]>:
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 <[email protected]>
<https://bugs.python.org/issue42328>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com