Managing continuous updates
Next, we will update the position of the seek bar knob and the elapsed play duration, as shown in the following screenshot:
This is nothing but a simple form of Tkinter-based animation.
The most common pattern of animating with Tkinter involves drawing a single frame and then calling the same method using the after
method of Tkinter, as follows:
def animate(self):
self.draw_frame()
self.after(500, self.animate)
Note
Once called, this function will keep updating frames once every 500 milliseconds. You can also add some conditions to break out of the animation loop.
Now that we know how to manage animations in Tkinter, let's ...
Get Tkinter GUI Application Development Blueprints now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.