tworld icon indicating copy to clipboard operation
tworld copied to clipboard

Timer event arguments

Open erkyrath opened this issue 11 years ago • 1 comments

When you send off a timer event with sched(), you might want to attach arguments to it, to be handed back when the event fires.

erkyrath avatar Sep 24 '13 03:09 erkyrath

You can now do this, slightly awkwardly, using functools.partial.

For example, if func is a code property that takes one argument, then this code will schedule a timer event that calls func("foo"):

sched(1, functools.partial(func, "foo"))

I'm leaving this issue open because I might come up with a better plan. Unfortunately the obvious:

sched(1, func, "foo")

...isn't compatible with the current sched() syntax. Might have to add sched_args() or something.

erkyrath avatar Nov 24 '13 23:11 erkyrath