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!
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With