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

Method after

Lib/tkinter/__init__.py:866–892  ·  view source on GitHub ↗

Call function once after given time. MS specifies the time in milliseconds. FUNC gives the function which shall be called. Additional parameters are given as parameters to the function call. Return identifier to cancel scheduling with after_cancel.

(self, ms, func=None, *args, **kw)

Source from the content-addressed store, hash-verified

864 return self._nametowidget(name)
865
866 def after(self, ms, func=None, *args, **kw):
867 """Call function once after given time.
868
869 MS specifies the time in milliseconds. FUNC gives the
870 function which shall be called. Additional parameters
871 are given as parameters to the function call. Return
872 identifier to cancel scheduling with after_cancel."""
873 if func is None:
874 # I'd rather use time.sleep(ms*0.001)
875 self.tk.call('after', ms)
876 return None
877 else:
878 def callit():
879 try:
880 func(*args, **kw)
881 finally:
882 try:
883 self.deletecommand(name)
884 except TclError:
885 pass
886 try:
887 callit.__name__ = func.__name__
888 except AttributeError:
889 # Required for callable classes (bpo-44404)
890 callit.__name__ = type(func).__name__
891 name = self._register(callit)
892 return self.tk.call('after', ms, name)
893
894 def after_idle(self, func, *args, **kw):
895 """Call FUNC once if the Tcl main loop has no event to

Callers 15

after_idleMethod · 0.95
_delayMethod · 0.80
_ontimerMethod · 0.80
test_afterMethod · 0.80
test_after_cancelMethod · 0.80
test_after_infoMethod · 0.80
callbackMethod · 0.80
test_mainloopMethod · 0.80
poll_subprocessMethod · 0.80
hide_eventMethod · 0.80
timer_eventMethod · 0.80

Calls 2

_registerMethod · 0.95
callMethod · 0.45

Tested by 8

test_afterMethod · 0.64
test_after_cancelMethod · 0.64
test_after_infoMethod · 0.64
callbackMethod · 0.64
test_mainloopMethod · 0.64
after_callbackFunction · 0.64
new_test_methodFunction · 0.64
test_del_with_timerMethod · 0.64