diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2022-09-27 11:05:05 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-27 11:05:05 (GMT) |
commit | adbed2d542a815b8175db965742211856b19b52f (patch) | |
tree | 02836d64eb0d9bf35c5519a8a69f11fb0e408dbf /Lib/test/test_ttk | |
parent | 68c46ae68b6e0c36a12e37285fff9ce0782ed01e (diff) | |
download | cpython-adbed2d542a815b8175db965742211856b19b52f.zip cpython-adbed2d542a815b8175db965742211856b19b52f.tar.gz cpython-adbed2d542a815b8175db965742211856b19b52f.tar.bz2 |
gh-73588: Fix generation of the default name of tkinter.Checkbutton. (GH-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.
Diffstat (limited to 'Lib/test/test_ttk')
-rw-r--r-- | Lib/test/test_ttk/test_widgets.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_ttk/test_widgets.py b/Lib/test/test_ttk/test_widgets.py index eb0cc93..6f47ccb 100644 --- a/Lib/test/test_ttk/test_widgets.py +++ b/Lib/test/test_ttk/test_widgets.py @@ -275,6 +275,21 @@ class CheckbuttonTest(AbstractLabelTest, unittest.TestCase): self.assertEqual(cbtn['offvalue'], cbtn.tk.globalgetvar(cbtn['variable'])) + def test_unique_variables(self): + frames = [] + buttons = [] + for i in range(2): + f = ttk.Frame(self.root) + f.pack() + frames.append(f) + for j in 'AB': + b = ttk.Checkbutton(f, text=j) + b.pack() + buttons.append(b) + variables = [str(b['variable']) for b in buttons] + print(variables) + self.assertEqual(len(set(variables)), 4, variables) + @add_standard_options(IntegerSizeTests, StandardTtkOptionsTests) class EntryTest(AbstractWidgetTest, unittest.TestCase): |