self.deletecommand(name)
except TclError:
pass
- callit.__name__ = func.__name__
+ try:
+ callit.__name__ = func.__name__
+ except AttributeError:
+ # Required for callable classes (bpo-44404)
+ callit.__name__ = type(func).__name__
name = self._register(callit)
return self.tk.call('after', ms, name)
+import functools
import unittest
import tkinter
import enum
with self.assertRaises(tkinter.TclError):
root.tk.call(script)
+ # Call with a callable class
+ count = 0
+ timer1 = root.after(0, functools.partial(callback, 42, 11))
+ root.update() # Process all pending events.
+ self.assertEqual(count, 53)
+
def test_after_idle(self):
root = self.root
--- /dev/null
+:mod:`tkinter`'s ``after()`` method now supports callables without the ``__name__`` attribute.