Skip to content
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

Changes to tkinter result in (unexpected) widget map call return changes wrt. 3.7 #82842

Closed
jslvtr mannequin opened this issue Nov 1, 2019 · 2 comments
Closed

Changes to tkinter result in (unexpected) widget map call return changes wrt. 3.7 #82842

jslvtr mannequin opened this issue Nov 1, 2019 · 2 comments
Labels
3.8 only security fixes OS-windows topic-tkinter type-bug An unexpected behavior, bug, or error

Comments

@jslvtr
Copy link
Mannequin

jslvtr mannequin commented Nov 1, 2019

BPO 38661
Nosy @pfmoore, @tjguk, @zware, @serhiy-storchaka, @zooba, @j4321, @jslvtr
Superseder
  • bpo-42328: ttk style.map function incorrectly handles the default state for element options.
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2020-12-19.17:47:23.960>
    created_at = <Date 2019-11-01.14:32:27.901>
    labels = ['3.8', 'type-bug', 'expert-tkinter', 'OS-windows']
    title = 'Changes to tkinter result in (unexpected) widget map call return changes wrt. 3.7'
    updated_at = <Date 2020-12-19.17:47:23.959>
    user = 'https://github.com/jslvtr'

    bugs.python.org fields:

    activity = <Date 2020-12-19.17:47:23.959>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-12-19.17:47:23.960>
    closer = 'serhiy.storchaka'
    components = ['Tkinter', 'Windows']
    creation = <Date 2019-11-01.14:32:27.901>
    creator = 'jslvtr'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 38661
    keywords = []
    message_count = 2.0
    messages = ['355818', '383091']
    nosy_count = 7.0
    nosy_names = ['paul.moore', 'tim.golden', 'zach.ware', 'serhiy.storchaka', 'steve.dower', 'j-4321-i', 'jslvtr']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '42328'
    type = 'behavior'
    url = 'https://bugs.python.org/issue38661'
    versions = ['Python 3.8']

    @jslvtr
    Copy link
    Mannequin Author

    jslvtr mannequin commented Nov 1, 2019

    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.

    @jslvtr jslvtr mannequin added 3.8 only security fixes topic-tkinter OS-windows type-bug An unexpected behavior, bug, or error labels Nov 1, 2019
    @serhiy-storchaka
    Copy link
    Member

    This was likely caused by different versions of Tk.

    It should be fixed now in bpo-42328. Style.map() should convert result to uniform representation on all versions and platforms, and accept input in different forms. Please check.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes OS-windows topic-tkinter type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant