from tkinter import *
import emoji
root = Tk()
root.geometry("300x300")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Radar de Velocidade")
titulo = Label(text="Radar de Velocidade",
font=("Arial", "20", "bold"), bg="#103030", fg="#49e3e3")
titulo.place(relx=0.03, rely=0.05)
sub1 = Label(text="Velocidade",
font=("Arial", "16", "bold"), bg="#103030", fg="#49e3e3")
sub1.place(relx=0.35, rely=0.25)
Velocidade = StringVar()
Velocidade_entrada = Entry(textvariable=Velocidade,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Velocidade_entrada.place(relx=0.3, rely=0.35, relwidth=0.45)
Velocidade_entrada.focus()
def limpar():
Velocidade_entrada.delete(0, END)
resultado_texto.config(text="")
def app():
try:
v = int(Velocidade.get())
if v <= 50:
mensagem = emoji.emojize("Velocidade dentro do limite. :smile:", use_aliases=True)
else:
mensagem = emoji.emojize("Você ultrapassou o limite de velocidade! :police_car:", use_aliases=True)
resultado_texto.config(text=mensagem)
except ValueError:
mensagem = "Por favor, insira um valor numérico."
resultado_texto.config(text=mensagem)
but1 = Button(text="Mostrar", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=app)
but1.place(relx=0.1, rely=0.55, 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.55, relwidth=0.25, relheight=0.1)
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.55, relwidth=0.25, relheight=0.1)
resultado_texto = Label(font=("Arial", 12, "bold"), bg="#cfe2f3")
resultado_texto.place(relx=0.05, rely=0.7, relwidth=0.9, relheight=0.15)
root.mainloop()
Comentários
Enviar um comentário