-
-
Notifications
You must be signed in to change notification settings - Fork 32k
Problem with Checkbutton and duplicate last name components #73588
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
Report and code from George Trojan on python-list. import tkinter
class GUI(tkinter.Tk):
def __init__(self):
tkinter.Tk.__init__(self)
frame = tkinter.Frame(self)
for tag in ('A', 'B'):
w = tkinter.Checkbutton(frame, text=tag)
w.pack(side='top', padx=10, pady=10)
print(w)
frame.pack(side='top')
frame = tkinter.Frame(self)
for tag in ('C', 'D'):
w = tkinter.Checkbutton(frame, text=tag)
w.pack(side='top', padx=10, pady=10)
print(w)
frame.pack(side='top')
gui = GUI()
gui.mainloop() In 3.5, each Checkbutton has unique last name component. In 3.6, last name components are duplicated I verified that the _w strings passed in tk.call are the full unique names. MRAB reported that adding a tk variable attribute fixed the problem. I notice that Brian Oakley said the same thing in the similar issue bpo-25684, though that is marked for 2.7 and 3.5 also. |
The variable option of the checkbutton widget specifies the name of a global variable to set to indicate whether or not this button is selected. It defaults to the name of the button within its parent (i.e. the last element of the button window's path name). There are two workarounds: specify either name or variable arguments explicitly. There can be similar issues with other widgets. |
Here is a sample patch that makes implicit variables for checkbuttons unique. This is one of ways to solve this issue. But I'm not sure that this issue needs to be solved at all. In real applications Checkbutton() is called with the variable argument, otherwise it would be not very useful. Only sample code can call Checkbutton() without the variable argument. |
…tton. Previously, checkbuttons in different parent widgets could have the same short name and share the same state if arguments "name" and "variable" are not specified. Now they are globally unique.
…tton. Previously, checkbuttons in different parent widgets could have the same short name and share the same state if arguments "name" and "variable" are not specified. Now they are globally unique.
PR #97547 slightly differs from the initial patch. It makes the last element of the name unique by default instead of making the checkbutton variable. If you implicitly specify the same
|
…H-97547) Previously, checkbuttons in different parent widgets could have the same short name and share the same state if arguments "name" and "variable" are not specified. Now they are globally unique.
…tton. (pythonGH-97547) Previously, checkbuttons in different parent widgets could have the same short name and share the same state if arguments "name" and "variable" are not specified. Now they are globally unique. (cherry picked from commit adbed2d) Co-authored-by: Serhiy Storchaka <[email protected]>
…tton. (pythonGH-97547) Previously, checkbuttons in different parent widgets could have the same short name and share the same state if arguments "name" and "variable" are not specified. Now they are globally unique. (cherry picked from commit adbed2d) Co-authored-by: Serhiy Storchaka <[email protected]>
…H-97547) Previously, checkbuttons in different parent widgets could have the same short name and share the same state if arguments "name" and "variable" are not specified. Now they are globally unique. (cherry picked from commit adbed2d) Co-authored-by: Serhiy Storchaka <[email protected]>
…H-97547) Previously, checkbuttons in different parent widgets could have the same short name and share the same state if arguments "name" and "variable" are not specified. Now they are globally unique. (cherry picked from commit adbed2d) Co-authored-by: Serhiy Storchaka <[email protected]>
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: