MCPcopy Index your code
hub / github.com/python/cpython / test_trace_variable

Method test_trace_variable

Lib/test/test_ttk/test_extensions.py:307–321  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

305 optmenu2.destroy()
306
307 def test_trace_variable(self):
308 # prior to bpo45160, tracing a variable would cause the callback to be made twice
309 success = []
310 items = ('a', 'b', 'c')
311 textvar = tkinter.StringVar(self.root)
312 def cb_test(*args):
313 success.append(textvar.get())
314 optmenu = ttk.OptionMenu(self.root, textvar, "a", *items)
315 optmenu.pack()
316 cb_name = textvar.trace_add("write", cb_test)
317 optmenu['menu'].invoke(1)
318 self.assertEqual(success, ['b'])
319 self.assertEqual(textvar.get(), 'b')
320 textvar.trace_remove("write", cb_name)
321 optmenu.destroy()
322
323 def test_specify_name(self):
324 textvar = tkinter.StringVar(self.root)

Callers

nothing calls this directly

Calls 7

getMethod · 0.95
destroyMethod · 0.95
trace_addMethod · 0.80
trace_removeMethod · 0.80
packMethod · 0.45
invokeMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected