from tkinter import *
def converter_para_ano_islamico(ano_gregoriano):
ano_hijri = ((ano_gregoriano - 622) * 33) / 32
return round(ano_hijri)
def limpar():
ano_civil_entrada.delete(0, END)
resultado_texto.config(text="")
def converter_ano():
try:
ano = int(ano_civil.get())
ano_islamico = converter_para_ano_islamico(ano)
mensagem = f"O ano islâmico correspondente ao ano civil {ano} é {ano_islamico}."
resultado_texto.config(text=mensagem)
except ValueError:
resultado_texto.config(text="Erro de digitação")
root = Tk()
root.geometry("500x300")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Converter do ano civil para ano islâmico")
titulo = Label(text="Converter do ano civil para ano islâmico",
font=("Arial", "18", "bold"), bg="#103030", fg="#49e3e3")
titulo.place(relx=0.03, rely=0.05)
sub1 = Label(text="Ano Civil:",
font=("Arial", "14", "bold"), bg="#103030", fg="#49e3e3")
sub1.place(relx=0.3, rely=0.25)
ano_civil = StringVar()
ano_civil_entrada = Entry(textvariable=ano_civil,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
ano_civil_entrada.place(relx=0.55, rely=0.25, relwidth=0.25)
ano_civil_entrada.focus()
but1 = Button(text="Converter", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=converter_ano)
but1.place(relx=0.1, rely=0.45, 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.45, 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.45, relwidth=0.25, relheight=0.1)
resultado_texto = Label(font=("Arial", 12, "bold"), bg="#cfe2f3", wraplength=400)
resultado_texto.place(relx=0.05, rely=0.68, relwidth=0.9, relheight=0.3)
root.mainloop()