Title: Changes to tkinter result in (unexpected) widget map call return changes wrt. 3.7
Type: behavior Stage: resolved
Components: Tkinter, Windows Versions: Python 3.8
Status: closed Resolution: duplicate
Dependencies: Superseder: ttk function incorrectly handles the default state for element options.
View: 42328
Assigned To: Nosy List: j-4321-i, jslvtr, paul.moore, serhiy.storchaka, steve.dower, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2019-11-01 14:32 by jslvtr, last changed 2020-12-19 17:47 by serhiy.storchaka. This issue is now closed.

Messages (2)
msg355818 - (view) Author: Jose Salvatierra (jslvtr) Date: 2019-11-01 14:32

I've encountered what might be a bug.

Up till now we had some working code that did this:

maps ='TCombobox')
if maps:'DateEntry', **maps)

Modifying a custom style to mimic the map of another. This has worked fine until Python 3.7, because the return value of `.map` is something that you can pass to `.map` as kw and it'll process it fine.

The return value of `.map` in Python 3.7 is something like this, for the `TCombobox`:

<class 'dict'>: {'focusfill': [('readonly', 'focus', 'SystemHighlight')], 'foreground': [('disabled', 'SystemGrayText'), ('readonly', 'focus', 'SystemHighlightText')], 'selectforeground': [('!focus', 'SystemWindowText')], 'selectbackground': [('!focus', 'SystemWindow')]}

Which is as you'd expect (and the docs say): a dictionary of properties to lists, where each list can contain multiple tuples describing the required state and final value of the property.

However in Python 3.8, the value returned by `.map` is this:

<class 'dict'>: {'focusfill': ['readonly focus', 'SystemHighlight'], 'foreground': ['disabled', 'SystemGrayText', 'readonly focus', 'SystemHighlightText'], 'selectforeground': ['!focus', 'SystemWindowText'], 'selectbackground': ['!focus', 'SystemWindow']}

The tuples are missing. This then causes a number of problems downstream, such as the final property values being split into the constituent letters instead of the values within each tuple.
msg383091 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-12-15 19:38
This was likely caused by different versions of Tk.

It should be fixed now in issue42328. should convert result to uniform representation on all versions and platforms, and accept input in different forms. Please check.
Date User Action Args
2020-12-19 17:47:23serhiy.storchakasetstatus: pending -> closed
stage: resolved
2020-12-15 19:38:46serhiy.storchakasetstatus: open -> pending
superseder: ttk function incorrectly handles the default state for element options.
resolution: duplicate
messages: + msg383091
2019-11-07 14:57:49j-4321-isetnosy: + j-4321-i
2019-11-01 15:31:56serhiy.storchakasetnosy: + serhiy.storchaka
2019-11-01 14:32:27jslvtrcreate