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!

2
  • 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. Commented Apr 15, 2014 at 13:07
  • Can you post some code. It sounds like you are using the after method incorrectly. Commented Apr 15, 2014 at 13:15

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.