Skip to content

Tkinter checkbutton switch on and off together #83079

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

Closed
zazahohonini mannequin opened this issue Nov 22, 2019 · 5 comments
Closed

Tkinter checkbutton switch on and off together #83079

zazahohonini mannequin opened this issue Nov 22, 2019 · 5 comments
Labels

Comments

@zazahohonini
Copy link
Mannequin

zazahohonini mannequin commented Nov 22, 2019

BPO 38898
Nosy @serhiy-storchaka
Superseder
  • bpo-29402: Problem with Checkbutton and duplicate last name components
  • Files
  • tkinter-checkbutton-bug.ogv: Video demonstatring the problem
  • 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 2019-11-28.07:04:43.816>
    created_at = <Date 2019-11-22.21:16:20.107>
    labels = ['3.8', '3.7', 'expert-tkinter']
    title = 'Tkinter checkbutton switch on and off together'
    updated_at = <Date 2019-11-28.07:04:43.815>
    user = 'https://bugs.python.org/zazahohonini'

    bugs.python.org fields:

    activity = <Date 2019-11-28.07:04:43.815>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-11-28.07:04:43.816>
    closer = 'serhiy.storchaka'
    components = ['Tkinter']
    creation = <Date 2019-11-22.21:16:20.107>
    creator = 'zaza hohonini'
    dependencies = []
    files = ['48741']
    hgrepos = []
    issue_num = 38898
    keywords = []
    message_count = 2.0
    messages = ['357323', '357375']
    nosy_count = 3.0
    nosy_names = ['gpolo', 'serhiy.storchaka', 'zaza hohonini']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '29402'
    type = None
    url = 'https://bugs.python.org/issue38898'
    versions = ['Python 3.6', 'Python 3.7', 'Python 3.8']

    @zazahohonini
    Copy link
    Mannequin Author

    zazahohonini mannequin commented Nov 22, 2019

    Hello,

    I am running python 3.8.0 and found a problem where multiple checkbuttons get switched when I click one. From observing it looks like each first check button in a frame is linked. And each second, etc. I ran the some program in python 2.7.17 and it works as expected.

    Basic program that show the problem:

    import tkinter as tk
    
    class Hello(tk.Frame):                     
        def __init__(self, parent=None):
            tk.Frame.__init__(self, parent)
            check = tk.Checkbutton(self, text='Checkbutton')
            check.pack()
    
    root = tk.Tk()
    Hello(root).pack()
    Hello(root).pack()
    root.mainloop()

    @zazahohonini zazahohonini mannequin added 3.8 (EOL) end of life topic-tkinter labels Nov 22, 2019
    @zazahohonini
    Copy link
    Mannequin Author

    zazahohonini mannequin commented Nov 23, 2019

    Hello,

    I have done a bit of digging and found out that this behavior appeared in python version 3.6.0 alpha2. I think it is related to bpo-27025
    (https://bugs.python.org/issue27025) that changed the way that widgets are named. It is my impression that the code that determines which checkbutton should have its appearance changed has not been changed accordingly.

    I also observe that if I use variable=tk.IntVar() as additional argument to tk.Checkbutton, normal behavior is restored. This is the easiest work around.

    @zazahohonini zazahohonini mannequin added the 3.7 (EOL) end of life label Nov 23, 2019
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @questaware
    Copy link

    I am running python 3.10 Tk/Tcl 3.6.10.

    It seems that the problem is more widespread.

    Adding variable=tk.IntVar() does fix the above problem but there is also this problem:

    cb3.txt

    @questaware
    Copy link

    questaware commented Sep 22, 2022

    Is seems that Checkbutton(frame, variable=myVar) does not cause Checkbutton to retain a python reference to myVar so that it can be garbage collected. Presumably this bug/behaviour occurs because the implementation is in "C"? Of course the system must retain a reference to myVar in some form so that it can update myVar when the button is clicked!

    @serhiy-storchaka
    Copy link
    Member

    This issue was closed as a duplicate of #73588.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants