Re: glib.timeout_add doesn't works well



if (condition):
          glib.timeout_add(i,f)
 
def f:

        (...)
        i = (....)
        (condition)
        return True

Even the value of "i" is different each time I call "f", glib.timeout_add(i,f) call "f" always with the same value of "i".

Changing the value of "i" will not change the timeout because it was already called and the value of "i" was copied there when passing the parameter. You must call the timeout again like this:

if (condition):
  glib.timeout_add(first_timeout, f)
 
def f:

  (...)
  i = (....)
  if (condition):
    glib.timeout_add(i, f) # This will start another timeout with the new interval
  return False # This will end this timeout!

Regards,
Ian L. Rodrigues


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]