Mundo em Python

Letra Aleatória

from tkinter import *
import random
Lista = ["A","B","C","D","E","F","G","H","I","J","L","M","N","O","P","Q","R","S","T","U","V","X","Z"]
root = Tk()
root.geometry("700x300")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Letra Aleatória")
titulo = Label(
text="Letra Aleatória",
font=("Arial", 28, "bold"),
bg="#103030",
fg="#49e3e3"
)
titulo.place(relx=0.3, rely=0.05) def app():
letra_sorteada = random.choice(Lista)
resultado_texto.config(text=f"Letra sorteada: {letra_sorteada}") def limpar():
resultado_texto.config(text="") but1 = Button(
text="Verificar",
bd=2,
bg='#107db2',
fg='white',
font=('verdana', 12, 'bold'),
command=app
)
but1.place(relx=0.1, rely=0.25, relwidth=0.25, relheight=0.1)
but_limpar = Button(
text="Limpar",
bd=2,
bg='#107db2',
fg='white',
font=('verdana', 12, 'bold'),
command=limpar
)
but_limpar.place(relx=0.4, rely=0.25, relwidth=0.25, relheight=0.1) # Botão Sair
but_sair = Button(
text="Sair",
bd=2,
bg='#107db2',
fg='white',
font=('verdana', 12, 'bold'),
command=root.destroy
)
but_sair.place(relx=0.7, rely=0.25, relwidth=0.25, relheight=0.1)
resultado_texto = Label(
text="",
font=("Arial", 20, "bold"),
bg="#cfe2f3"
)
resultado_texto.place(relx=0.05, rely=0.45, relwidth=0.9, relheight=0.45)
root.mainloop()
0