summaryrefslogtreecommitdiffstats
path: root/Lib/tkinter/test
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-10-21 21:02:20 (GMT)
committerGitHub <noreply@github.com>2021-10-21 21:02:20 (GMT)
commit98f157de1260801fd26c72eb6bfae0d9295e5ab3 (patch)
tree0ebf23084274621714c64a895c11517d7e2d6250 /Lib/tkinter/test
parent828722aca4ccba893f6b2e8c1d41fd74fd6e208d (diff)
downloadcpython-98f157de1260801fd26c72eb6bfae0d9295e5ab3.zip
cpython-98f157de1260801fd26c72eb6bfae0d9295e5ab3.tar.gz
cpython-98f157de1260801fd26c72eb6bfae0d9295e5ab3.tar.bz2
bpo-45160: Ttk optionmenu only set variable once (GH-28291) (GH-29131)
(cherry picked from commit add46f84769a7e6fafa50954f79b7c248231fa4e) Co-authored-by: E-Paine <63801254+E-Paine@users.noreply.github.com>
Diffstat (limited to 'Lib/tkinter/test')
-rw-r--r--Lib/tkinter/test/test_ttk/test_extensions.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/tkinter/test/test_ttk/test_extensions.py b/Lib/tkinter/test/test_ttk/test_extensions.py
index 438d21d..cddd1f2 100644
--- a/Lib/tkinter/test/test_ttk/test_extensions.py
+++ b/Lib/tkinter/test/test_ttk/test_extensions.py
@@ -301,6 +301,19 @@ class OptionMenuTest(AbstractTkTest, unittest.TestCase):
optmenu.destroy()
optmenu2.destroy()
+ def test_trace_variable(self):
+ # prior to bpo45160, tracing a variable would cause the callback to be made twice
+ success = []
+ items = ('a', 'b', 'c')
+ textvar = tkinter.StringVar(self.root)
+ def cb_test(*args):
+ self.assertEqual(textvar.get(), items[1])
+ success.append(True)
+ optmenu = ttk.OptionMenu(self.root, textvar, "a", *items)
+ textvar.trace("w", cb_test)
+ optmenu['menu'].invoke(1)
+ self.assertEqual(success, [True])
+
class DefaultRootTest(AbstractDefaultRootTest, unittest.TestCase):