dimanche 28 novembre 2021

How to display a YouTube Video in Jupyter Notebook by Clicking a Button Using Tkinter

I'm trying to display a random YouTube Video from a list of 2 videos in my Jupyter notebook by displaying a button and clicking it.

    import random
    from IPython.display import YouTubeVideo
    TODO =  (YouTubeVideo('-C-ic2H24OU', width=800, height=300), YouTubeVideo('NpPDgrbmAYQ', width=800, height=300))
    random_choice_from_my_list = random.choice(TODO)
    random_choice_from_my_list

^This will display a random video from the TODO list

import tkinter as tk
def TODO_ACTIVITY():
    random_choice_from_my_list   
root = tk.Tk()
frame = tk.Frame(root)
frame.pack()
button = tk.Button(frame, 
                   text="TO DO", 
                   fg="black",
                   command=TODO_ACTIVITY)
button.pack(side=tk.LEFT)
root.mainloop()

^This will display the button

Nothing happens when I click the button. Any ideas?




Aucun commentaire:

Enregistrer un commentaire