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: Tkinter checkbutton switch on and off together
Type: Stage: resolved
Components: Tkinter Versions: Python 3.8, Python 3.7, Python 3.6
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Problem with Checkbutton and duplicate last name components
View: 29402
Assigned To: Nosy List: gpolo, serhiy.storchaka, zaza hohonini
Priority: normal Keywords:

Created on 2019-11-22 21:16 by zaza hohonini, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
tkinter-checkbutton-bug.ogv zaza hohonini, 2019-11-22 21:16 Video demonstatring the problem
Messages (2)
msg357323 - (view) Author: zaza hohonini (zaza hohonini) Date: 2019-11-22 21:16
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()
msg357375 - (view) Author: zaza hohonini (zaza hohonini) Date: 2019-11-23 11:03
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.
History
Date User Action Args
2022-04-11 14:59:23adminsetgithub: 83079
2019-11-28 07:04:43serhiy.storchakasetstatus: open -> closed
superseder: Problem with Checkbutton and duplicate last name components
resolution: duplicate
stage: resolved
2019-11-28 06:18:39ned.deilysetnosy: + gpolo, serhiy.storchaka
2019-11-23 11:03:34zaza hohoninisetmessages: + msg357375
versions: + Python 3.6, Python 3.7
2019-11-22 21:16:20zaza hohoninicreate