I have a simple pokemon-battle type project I'm doing for a college but I want to add more visuals to it by adding small 2 sec animations that plays everytime a button is clicked. I thought about using a toplevel window which plays a video using tkvideo. It works, but I can't figure out how to close it after 2 secs OR after it loops the video once.
Can anyone offer suggestions to a newbie? P.S. I used Toplevel because there is already a main root window where the player can click buttons.
from tkinter import *
from tkvideo import tkvideo
window = tkinter.Toplevel()
window.title("Video PLayer")
lblVideo = Label(window)
lblVideo.pack()
player = tkvideo("Hero_Slash_Attack_Animation.mp4", lblVideo, loop=1, size=(500,500),)
player.play()
window.mainloop()
The code up above is what I used to play a secondary video window but. But I can't figure out how to close that specific top level. I tried w.destroy() but it didn't remove it. Instead, the video just keeps looping and staying.
You can use
tkVideoPlayer
instead oftkvideo
. Here is a link to the documentation.For example: