Consumir Álcool

from tkinter import *
from datetime import datetime
root = Tk()
root.geometry("400x400")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Consumir Álcool ")
titulo = Label(text="Verificar se pode beber álcool ",
font=("Arial", "19", "bold"), bg="#103030", fg="#49e3e3")
titulo.place(relx=0.05, rely=0.05)
sub1 = Label(text="Data de Nascimento (YYYY-MM-DD) ", font=("Arial", "15", "bold"), bg="#103030", fg="#49e3e3")
sub1.place(relx=0.05, rely=0.25)
Data_Nascimento = StringVar()
Data_Nascimento_entrada = Entry(textvariable=Data_Nascimento, font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Data_Nascimento_entrada.place(relx=0.35, rely=0.35, relwidth=0.35)
Data_Nascimento_entrada.focus()

def limpar():
Data_Nascimento_entrada.delete(0,END)
resultado_texto.set("")


def app():
data = Data_Nascimento.get()
data_atual = datetime.now()
ano_atual = data_atual.year
mes_atual = data_atual.month
dia_atual = data_atual.day

ano_nascimento, mes_nascimento, dia_nascimento = map(int, data.split('-'))

idade = ano_atual - ano_nascimento
if (mes_atual, dia_atual) < (mes_nascimento, dia_nascimento):
idade -= 1

if idade < 18:
mensagem = "Não tem idade legal para beber álcool."
else:
mensagem = "Pode beber álcool."

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

Mensagens populares deste blogue

Criar Cartões de Visita

12 signos egípcios

Calcular a percentagem de ocupação