dimanche 27 février 2022

How do I make a label disappear after 5 seconds python, Tkinter?

I am making a dice roller, and I wish to make the result of the dice roll disappear after 5 seconds, can anyone help?

from tkinter import *
import random
root=Tk()
root.geometry('700x500')
root.title("Dice roller")
bg = PhotoImage(file = "background.png")
Label1 = Label(root, image = bg)
Label1.place (x = 0, y=0)
l = Label(root, text="Welcome to the dice roller, select the dice you want to roll!",bg = "gold",fg = "goldenrod4", relief = "raised", font=("Arial Bold",12))
l.pack()


def buttonFunction1():
    r1 = random.randint(1, 6)
    L = Label(root, text= r1, bg = "red", relief = "solid", cursor = "target", font = ("Arial Bold", 10)) 
###That was the label I want to make disappear after 5 seconds###
    L.place(relx = 0.8, rely = 0.14, anchor = 'sw') 
b = Button(root, text="cube dice", command= buttonFunction1)
b.pack()



Aucun commentaire:

Enregistrer un commentaire