bpo-27313: Use non-deprecated methods for tracing (GH-29425)

This commit is contained in:
Serhiy Storchaka 2021-11-06 21:01:39 +02:00 committed by GitHub
parent 57457a1e5c
commit cc1cbcbb2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 5 deletions

View File

@ -307,14 +307,14 @@ class OptionMenuTest(AbstractTkTest, unittest.TestCase):
items = ('a', 'b', 'c') items = ('a', 'b', 'c')
textvar = tkinter.StringVar(self.root) textvar = tkinter.StringVar(self.root)
def cb_test(*args): def cb_test(*args):
self.assertEqual(textvar.get(), items[1]) success.append(textvar.get())
success.append(True)
optmenu = ttk.OptionMenu(self.root, textvar, "a", *items) optmenu = ttk.OptionMenu(self.root, textvar, "a", *items)
optmenu.pack() optmenu.pack()
cb_name = textvar.trace("w", cb_test) cb_name = textvar.trace_add("write", cb_test)
optmenu['menu'].invoke(1) optmenu['menu'].invoke(1)
self.assertEqual(success, [True]) self.assertEqual(success, ['b'])
textvar.trace_vdelete("w", cb_name) self.assertEqual(textvar.get(), 'b')
textvar.trace_remove("write", cb_name)
optmenu.destroy() optmenu.destroy()