from tkinter import *
def classificar_ouro(pureza_input):
if isinstance(pureza_input, str) and pureza_input.endswith('K'):
try:
quilates = int(pureza_input.replace('K', ''))
except ValueError:
return "Entrada inválida. Use um número de quilates (ex: '18K') ou milésimos (ex: 750)."
if quilates == 24:
return "Ouro 24 Quilates (24K): Ouro puro (99.9%+). Muito macio, usado em barras e moedas."
elif quilates == 22:
return "Ouro 22 Quilates (22K): 91.6% de ouro puro. Usado em joias de algumas culturas."
elif quilates == 19:
return "Ouro 19.2 Quilates (19.2K): Ouro Português (80% de ouro puro). Comum em Portugal."
elif quilates == 18:
return "Ouro 18 Quilates (18K): 75% de ouro puro. Ouro mais comum na joalheria mundial."
elif quilates == 14:
return "Ouro 14 Quilates (14K): 58.3% de ouro puro. Mais durável e acessível."
elif quilates == 10:
return "Ouro 10 Quilates (10K): 41.6% de ouro puro. O mais durável e acessível, menor teor."
else:
return f"Pureza em quilates ({pureza_input}) não reconhecida ou fora das classificações comuns."
elif isinstance(pureza_input, (int, float)) or (isinstance(pureza_input, str) and pureza_input.isdigit()):
pureza_milesimos = int(pureza_input)
if 999 <= pureza_milesimos <= 1000:
return "Ouro 24 Quilates (Ouro 999): Ouro puro (99.9%+). Muito macio, usado em barras e moedas."
elif pureza_milesimos == 916:
return "Ouro 22 Quilates (Ouro 916): 91.6% de ouro puro. Usado em joias de algumas culturas."
elif pureza_milesimos == 800:
return "Ouro 19.2 Quilates (Ouro 800): Ouro Português (80% de ouro puro). Comum em Portugal."
elif pureza_milesimos == 750:
return "Ouro 18 Quilates (Ouro 750): 75% de ouro puro. Ouro mais comum na joalheria mundial."
elif 583 <= pureza_milesimos <= 585:
return "Ouro 14 Quilates (Ouro 583/585): 58.3% de ouro puro. Mais durável e acessível."
elif 416 <= pureza_milesimos <= 417:
return "Ouro 10 Quilates (Ouro 416/417): 41.6% de ouro puro. O mais durável e acessível, menor teor."
else:
return f"Pureza em milésimos ({pureza_input}) não reconhecida ou fora das classificações comuns."
else:
return "Entrada inválida. Por favor, insira a pureza em quilates (ex: '18K') ou em milésimos (ex: 750)."
# Interface Tkinter
root = Tk()
root.geometry("600x400")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Classificação do Ouro")
titulo = Label(text="Classificação do Ouro", font=("Arial", 28, "bold"), bg="#103030", fg="#49e3e3")
titulo.place(relx=0.15, rely=0.05)
texto_sub1 = Label(text="Informe a pureza (ex: 18K ou 750):", font=("Arial", 16), bg="#103030", fg="#49e3e3")
texto_sub1.place(relx=0.15, rely=0.25)
entrada = Entry(font=("Arial", 14))
entrada.place(relx=0.15, rely=0.35, relwidth=0.7, relheight=0.08)
resultado_texto = Label(text="", font=("Arial", 12, "bold"), bg="#cfe2f3", wraplength=520, justify=LEFT)
resultado_texto.place(relx=0.05, rely=0.8, relwidth=0.9, relheight=0.15)
# Função do botão Mostrar
def app():
valor = entrada.get().strip()
resultado = classificar_ouro(valor)
resultado_texto.config(text=resultado)
# Botões
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=lambda: resultado_texto.config(text=""))
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)
root.mainloop()