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:
def play(self) :
self.play = True
s = sched.scheduler(time.time, time.sleep)
s.enter(1, 1, self.playRec, (s,))
s.run()
def playRec(self, sc) :
if self.play :
self.updateGrid()
print "blah"
sc.enter(5, 1, self.playRec, (sc,))
def play(self) :
self.play = True
s = sched.scheduler(time.time, time.sleep)
s.enter(1, 1, self.playRec, (s,))
s.run()
def playRec(self, sc) :
if self.play :
self.updateGrid()
print "blah"
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!
Bookmarks