Skip to content

bpo-42328: Fix tkinter.ttk.Style.map(). #23300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Nov 15, 2020

It accepts now the default state as returned by Style.map().

https://bugs.python.org/issue42328

It accepts now the default state as returned by Style.map().
@serhiy-storchaka serhiy-storchaka changed the title Fix tkinter.ttk.Style.map(). bpo-42328: Fix tkinter.ttk.Style.map(). Nov 15, 2020
@serhiy-storchaka serhiy-storchaka force-pushed the ttk-style-map-default-state branch from b86968f to 683a7a9 Compare November 15, 2020 16:13

# Single state
for states in ['active'], [('active',)]:
style.map('TButton', background=[('active', 'white')])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The loop variable states is not used in the loop, making it irrelevant. By analogy with the next 2 loops, did you mean

Suggested change
style.map('TButton', background=[('active', 'white')])
style.map('TButton', background=[(*states, 'white')])

?

@terryjreedy
Copy link
Member

terryjreedy commented Nov 15, 2020

The GH Windows failure test logs are not available. The Pipelines logs are and same on win32 and win64

======================================================================
FAIL: test_map (tkinter.test.test_ttk.test_style.StyleTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\a\1\s\lib\tkinter\test\test_ttk\test_style.py", line 45, in test_map
    self.assertEqual(m['background'], [('active', 'white')])
AssertionError: Lists differ: ['active', 'white'] != [('active', 'white')]
======================================================================
FAIL: test_map_custom_copy (tkinter.test.test_ttk.test_style.StyleTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\a\1\s\lib\tkinter\test\test_ttk\test_style.py", line 184, in test_map_custom_copy
    self.assertEqual(style.map(newname, key), value)
AssertionError: Lists differ: [('!disabled pressed', 'sunken')] != [('!disabled', 'pressed', 'sunken')]

@patthoyts
Copy link

Works for me on Windows now. ttk tests passed and cloning a map with default state works. I assume we want to withdraw my pull-request then?

@serhiy-storchaka serhiy-storchaka merged commit dd844a2 into python:master Nov 22, 2020
@miss-islington
Copy link
Contributor

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8, 3.9.
🐍🍒⛏🤖

@serhiy-storchaka serhiy-storchaka deleted the ttk-style-map-default-state branch November 22, 2020 20:48
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 22, 2020
The function accepts now the representation of the default state as
empty sequence (as returned by Style.map()).
The structure of the result is now the same on all platform
and does not depend on the value of wantobjects.
(cherry picked from commit dd844a2)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@bedevere-bot
Copy link

GH-23470 is a backport of this pull request to the 3.9 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.9 only security fixes label Nov 22, 2020
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 22, 2020
The function accepts now the representation of the default state as
empty sequence (as returned by Style.map()).
The structure of the result is now the same on all platform
and does not depend on the value of wantobjects.
(cherry picked from commit dd844a2)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@bedevere-bot
Copy link

GH-23471 is a backport of this pull request to the 3.8 branch.

miss-islington added a commit that referenced this pull request Nov 23, 2020
The function accepts now the representation of the default state as
empty sequence (as returned by Style.map()).
The structure of the result is now the same on all platform
and does not depend on the value of wantobjects.
(cherry picked from commit dd844a2)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
miss-islington added a commit that referenced this pull request Nov 23, 2020
The function accepts now the representation of the default state as
empty sequence (as returned by Style.map()).
The structure of the result is now the same on all platform
and does not depend on the value of wantobjects.
(cherry picked from commit dd844a2)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 13, 2021
The function accepts now the representation of the default state as
empty sequence (as returned by Style.map()).
The structure of the result is now the same on all platform
and does not depend on the value of wantobjects.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants