diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2024-03-16 11:31:19 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-16 11:31:19 (GMT) |
commit | c61cb507c10c5b597928284e087a9a384ab267d0 (patch) | |
tree | 3f0860771658c9b8e38f49a2c8de342655a9fcc2 /Lib/tkinter | |
parent | 1069a462f611f0b70b6eec0bba603d618a0378f3 (diff) | |
download | cpython-c61cb507c10c5b597928284e087a9a384ab267d0.zip cpython-c61cb507c10c5b597928284e087a9a384ab267d0.tar.gz cpython-c61cb507c10c5b597928284e087a9a384ab267d0.tar.bz2 |
gh-116484: Fix collisions between Checkbutton and ttk.Checkbutton default names (GH-116495)
Change automatically generated tkinter.Checkbutton widget names to
avoid collisions with automatically generated tkinter.ttk.Checkbutton
widget names within the same parent widget.
Diffstat (limited to 'Lib/tkinter')
-rw-r--r-- | Lib/tkinter/__init__.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py index 175bfbd..fd7b48e 100644 --- a/Lib/tkinter/__init__.py +++ b/Lib/tkinter/__init__.py @@ -3166,11 +3166,16 @@ class Checkbutton(Widget): Widget.__init__(self, master, 'checkbutton', cnf, kw) def _setup(self, master, cnf): + # Because Checkbutton defaults to a variable with the same name as + # the widget, Checkbutton default names must be globally unique, + # not just unique within the parent widget. if not cnf.get('name'): global _checkbutton_count name = self.__class__.__name__.lower() _checkbutton_count += 1 - cnf['name'] = f'!{name}{_checkbutton_count}' + # To avoid collisions with ttk.Checkbutton, use the different + # name template. + cnf['name'] = f'!{name}-{_checkbutton_count}' super()._setup(master, cnf) def deselect(self): |