How to check whether a thread has ended in Python
<p>I am working on my first app, and have been following some tutorials on how to setup a working GUI with tkinter and python. My application starts by playing a splash screen animation, and once it completes, switches to the "UserSetup" frame. I am still busy trying to re-code the function that plays this video so that I can call upon it as a method (or whatever works). What I wanted to know is, if there is a way to check once the thread which plays this video has stopped? Any other animations played now run concurrently, and I don't want that. I basically want it to only continue with the next set of animations or whatever once the splash screen animation has stopped.</p>

<p>It is quite a bit of code....</p>

<pre><code># ======================
# imports
# ======================
import tkinter as tk
import imageio
import threading
from PIL import Image, ImageTk

LARGE_FONT = ("Segoe UI", 18)


# =======================
# INITIALISATION - MAIN
# =======================
class MyApp(tk.Tk):
    def __init__(self, *args, **kwargs):
        tk.Tk.__init__(self, *args, **kwargs)
        container = tk.Frame(self)
        container.pack(side='top', fill='both', expand=True)
        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)

        self.frames = {}

        for F in (SplashScreen, UserSetup, TimerSetup):
            frame = F(container, self)
            self.frames[F] = frame
            frame.grid(row=0, column=0, sticky='nsew')
        self.show_frame(SplashScreen)


    def show_frame(self, cont):
        frame = self.frames[cont]
        frame.tkraise()


# ======================
# PAGES
# ======================
""" To add new pages, just create a page class which inherits from tk.Frame,
    add it to the dictionary, and add buttons for navigation """


class SplashScreen(tk.Frame):
    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)

        video_name = "img//splash.avi"  # This is your video file path
        video = imageio.get_reader(video_name)

        def stream(label):
            for image in video.iter_data():
                frame_image = ImageTk.PhotoImage(Image.fromarray(image))
                label.config(image=frame_image)
                label.image = frame_image
            controller.show_frame(UserSetup)

        def forget():
            my_label.pack_forget()

        my_label = tk.Label(self)
        my_label.pack()
        my_label.after(ms=15000, func=forget)
        thread = threading.Thread(target=stream, args=(my_label,))
        thread.daemon = 1
        thread.setName("splash")
        thread.start()
        print(thread.getName())


class UserSetup(tk.Frame):
    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)


class TimerSetup(tk.Frame):
    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)


# ======================
# INITIALISATION (MAIN)
# ======================
app = MyApp()
#app.overrideredirect(True)
app.mainloop()
</code></pre>