3

For a project I need to do, I code a Bomberman. I'm working with the software Pyzo, in Python language, and with Tkinter. The problem I have is that I need to a timer for the bomb, for example, I put a bomb and it exploded 3 seconds after. But I have tested with many different things like .after; time module (time.sleep), a loop. The consequence is always the same, the windows freezes and I can't move anymore, but when the loop is finished, the screen is refreshed and players are at new positions.

How can I do a proper timer to permit my bombs to explode after 3 seconds ? Thank you!

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
Sanguis
  • 31
  • 1
  • 1
    Can you post a code sample using the `after` method? That's probably going to be your best option, but it's hard to say where it went wrong without seeing it. – atlasologist Apr 15 '14 at 13:07
  • Can you post some code. It sounds like you are using the `after` method incorrectly. – ebarr Apr 15 '14 at 13:15

1 Answers1

2

You can use

widget.after(milliseconds, function, *arguments)

to let the function(*arguments) be called after milliseconds. If the function takes no arguments use widget.after(milliseconds, function). One argument widget.after(milliseconds, function, arg1), ....

widget can be Tk(), Canvas(), Frame(), Label(), ... object.

If you are interested in loops: tkinter loop and serial write

Community
  • 1
  • 1
User
  • 14,131
  • 2
  • 40
  • 59