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/test/test_ttk/test_widgets.py | |
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/test/test_ttk/test_widgets.py')
-rw-r--r-- | Lib/test/test_ttk/test_widgets.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/Lib/test/test_ttk/test_widgets.py b/Lib/test/test_ttk/test_widgets.py index fd1a748..e3e440c 100644 --- a/Lib/test/test_ttk/test_widgets.py +++ b/Lib/test/test_ttk/test_widgets.py @@ -285,9 +285,29 @@ class CheckbuttonTest(AbstractLabelTest, unittest.TestCase): b.pack() buttons.append(b) variables = [str(b['variable']) for b in buttons] - print(variables) self.assertEqual(len(set(variables)), 4, variables) + def test_unique_variables2(self): + buttons = [] + f = ttk.Frame(self.root) + f.pack() + f = ttk.Frame(self.root) + f.pack() + for j in 'AB': + b = tkinter.Checkbutton(f, text=j) + b.pack() + buttons.append(b) + # Should be larger than the number of all previously created + # tkinter.Checkbutton widgets: + for j in range(100): + b = ttk.Checkbutton(f, text=str(j)) + b.pack() + buttons.append(b) + names = [str(b) for b in buttons] + self.assertEqual(len(set(names)), len(buttons), names) + variables = [str(b['variable']) for b in buttons] + self.assertEqual(len(set(variables)), len(buttons), variables) + @add_standard_options(IntegerSizeTests, StandardTtkOptionsTests) class EntryTest(AbstractWidgetTest, unittest.TestCase): |