Reputation: 1802
When I try to call a function using a timeout in pyGtk, I receive the error message TypeError: second argument not callable
.
All I want to do is call a very simple function from within the time out. To illustrate my proble, I have simply prepared the function do_nothing
to illustrate my problem.
def do_nothing(self):
return True
# Do interval checks of the timer
def timed_check(self, widget):
self.check_timing = gobject.timeout_add(500, self.do_nothing())
which does not work...
What am I doing wrong?
Upvotes: 1
Views: 639
Reputation: 11
try instead:
self.check_timing = gobject.timeout_add(500, self.do_nothing, self)
Upvotes: 1
Reputation: 66729
Pass self.do_nothing and not self.do_nothing()
self.do_nothing is callable
self.do_nothing() returns a value and that return value is not a callable
Upvotes: 1
Reputation: 20671
You're calling the function:
self.do_nothing()
You want to pass the function:
self.do_nothing
Omit the parentheses.
Upvotes: 6