This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
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
process
Status: closed Resolution: duplicate
Dependencies: Superseder: ttk style.map 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 2022-04-11 14:59 by admin. This issue is now closed.

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

I've encountered what might be a bug.

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

```
maps = self.style.map('TCombobox')
if maps:
    self.style.map('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. Style.map() should convert result to uniform representation on all versions and platforms, and accept input in different forms. Please check.
History
Date User Action Args
2022-04-11 14:59:22adminsetgithub: 82842
2020-12-19 17:47:23serhiy.storchakasetstatus: pending -> closed
stage: resolved
2020-12-15 19:38:46serhiy.storchakasetstatus: open -> pending
superseder: ttk style.map 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