Mundo em Python

Simulador da Amizade

from tkinter import *
root = Tk()
root.geometry("700x500")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Simulador da Amizade")
titulo = Label(
text="Simulador da Amizade",font=("Arial", 28, "bold"),bg="#103030",fg="#49e3e3")
titulo.place(relx=0.18, rely=0.05) texto_sub1 = Label(text="Confiança (0-10):", font=("Arial", 16,"bold"), bg="#103030", fg="#49e3e3")
texto_sub1.place(relx=0.18, rely=0.2) texto_sub2 = Label(text="Sinceridade (0-10):", font=("Arial", 16,"bold"), bg="#103030", fg="#49e3e3")
texto_sub2.place(relx=0.15, rely=0.33) texto_sub3 = Label(text="Apoio (0-10):", font=("Arial", 16,"bold"), bg="#103030", fg="#49e3e3")
texto_sub3.place(relx=0.23, rely=0.43) texto_sub4 = Label(text="Momentos (0-10):", font=("Arial", 16,"bold"), bg="#103030", fg="#49e3e3")
texto_sub4.place(relx=0.15, rely=0.53) texto_sub5 = Label(text="Egoísmo (0-10):", font=("Arial", 16,"bold"), bg="#103030", fg="#49e3e3")
texto_sub5.place(relx=0.18, rely=0.63)
Confiança = StringVar()
Confiança_entrada = Entry(
textvariable=Confiança,
font=("Arial", 12, "bold"),
bg="white",
fg="blue",
justify='center'
)
Confiança_entrada.place(relx=0.5, rely=0.21, relwidth=0.35)
Confiança_entrada.focus() Sinceridade = StringVar()
Sinceridade_entrada = Entry(
textvariable=Sinceridade,
font=("Arial", 12, "bold"),
bg="white",
fg="blue",
justify='center'
)
Sinceridade_entrada.place(relx=0.5, rely=0.44, relwidth=0.35)
Apoio = StringVar()
Apoio_entrada = Entry(
textvariable=Apoio,
font=("Arial", 12, "bold"),
bg="white",
fg="blue",
justify='center'
)
Apoio_entrada.place(relx=0.5, rely=0.34, relwidth=0.35)
Momentos = StringVar()
Momentos_entrada = Entry(
textvariable=Momentos,
font=("Arial", 12, "bold"),
bg="white",
fg="blue",
justify='center'
)
Momentos_entrada.place(relx=0.5, rely=0.54, relwidth=0.35) Egoísmo = StringVar()
Egoísmo_entrada = Entry(
textvariable=Egoísmo,
font=("Arial", 12, "bold"),
bg="white",
fg="blue",
justify='center'
)
Egoísmo_entrada.place(relx=0.5, rely=0.63, relwidth=0.35) def limpar():
Egoísmo_entrada.delete(0, END)
Momentos_entrada.delete(0, END)
Apoio_entrada.delete(0, END)
Sinceridade_entrada.delete(0, END)
Confiança_entrada.delete(0, END)
resultado_texto.config(text="")
def app():
try:
E = float(Egoísmo.get())
M = float(Momentos.get())
A = float(Apoio.get())
S = float(Sinceridade.get())
C = float(Confiança.get()) Amizade = (C*0.30+S*0.20+A*0.25+M*0.15)-(E*0.10) if Amizade >= 8:
mensaegm ="Amizade Excelente"
elif Amizade >= 6:
mensaegm = "Amizade Forte"

elif Amizade >= 4:
mensaegm = "Amizade Estável"
elif Amizade >= 2:
mensaegm = "Amizade Frágil"
else:
mensaegm = "Amizade Muito Fraca"

resultado_texto.config(text=mensaegm)
except ValueError:
resultado_texto.config(text="Por favor, insira valores numéricos válidos") # Botões
but1 = Button(
text="Calcular",
bd=2,
bg='#107db2',
fg='white',
font=('verdana', 12, 'bold'),
command=app
)
but1.place(relx=0.1, rely=0.7, 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.7, 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.7, relwidth=0.25, relheight=0.1) resultado_texto = Label(
text="",
font=("Arial", 12, "bold"),
bg="#cfe2f3"
)
resultado_texto.place(relx=0.05, rely=0.85, relwidth=0.9, relheight=0.1)
root.mainloop()
0