Issue29402
Created on 2017-01-31 21:34 by terry.reedy, last changed 2022-04-11 14:58 by admin.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| tkinter-checkbutton-unique-variables.patch | serhiy.storchaka, 2017-03-03 20:52 | review | ||
| Messages (3) | |||
|---|---|---|---|
| msg286552 - (view) | Author: Terry J. Reedy (terry.reedy) * ![]() |
Date: 2017-01-31 21:34 | |
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.
.2028654224384.2028654606600
.2028654224384.2028654608224
.2028654606656.2028654606824
.2028654606656.2028654608336
Clicking any box checks or unchecks exactly that box.
In 3.6, last name components are duplicated
.!frame.!checkbutton
.!frame.!checkbutton2
.!frame2.!checkbutton
.!frame2.!checkbutton2
Clicking any box checks or unchecks both button with 'same name'.
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 #25684, though that is marked for 2.7 and 3.5 also.
|
|||
| msg286611 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2017-02-01 10:31 | |
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. |
|||
| msg288926 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2017-03-03 20:52 | |
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. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:42 | admin | set | github: 73588 |
| 2019-11-28 07:04:43 | serhiy.storchaka | link | issue38898 superseder |
| 2017-03-03 20:52:20 | serhiy.storchaka | set | files:
+ tkinter-checkbutton-unique-variables.patch keywords: + patch messages: + msg288926 stage: test needed -> patch review |
| 2017-03-03 15:42:50 | serhiy.storchaka | set | assignee: serhiy.storchaka |
| 2017-02-01 10:31:29 | serhiy.storchaka | set | messages:
+ msg286611 components: + Library (Lib), Tkinter |
| 2017-01-31 21:34:54 | terry.reedy | create | |
