-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
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
Comments
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() |
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 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. |
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: |
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! |
This issue was closed as a duplicate of #73588. |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: