mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
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.
This commit is contained in:
parent
1069a462f6
commit
c61cb507c1
3 changed files with 30 additions and 2 deletions
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue