Hello.

Here is what I want to do:
I have a QGraphicsScene containing a grid. I have a function updateGrid. I have a button step that updates manually the grid.
I want to make a button play that automatically updates the grid every n seconds.
I tried using Python sched but it seems to work fine to print in the console every n seconds, but when I set it up to update the grid, the whole application freezes and I must force it to quit.

Here is the code:

Qt Code:
  1. def play(self) :
  2. self.play = True
  3. s = sched.scheduler(time.time, time.sleep)
  4. s.enter(1, 1, self.playRec, (s,))
  5. s.run()
  6.  
  7.  
  8. def playRec(self, sc) :
  9. if self.play :
  10. self.updateGrid()
  11. print "blah"
  12. sc.enter(5, 1, self.playRec, (sc,))
To copy to clipboard, switch view to plain text mode 

How can I do this?

Thank you very much!