tags:

views:

16

answers:

2

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?

+3  A: 

You're calling the function:

self.do_nothing()

You want to pass the function:

self.do_nothing

Omit the parentheses.

Adam Vandenberg
Ridiculously simple. Thanks!
Ingo
+1  A: 

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

pyfunc