from tkinter import *
root = Tk()
root.geometry("400x400")
root.resizable(0, 0)
root.config(bg="#2065d4")
root.title("Resolver Equação Linear")
titulo = Label(text="Resolver Equação Linear",
font=("Arial", "23", "bold"),bg="#2065d4",fg="#d9ead3")
titulo.place(relx=0.04, rely=0.05)
texto_sub1 = Label(text="Coeficiente [a]:",
font=("Arial", "15", "bold"),bg="#2065d4",fg="#d9ead3")
texto_sub1.place(relx=0.17, rely=0.3)
texto_sub2 = Label(text="Termo Constante [b]:",
font=("Arial", "15", "bold"),bg="#2065d4",fg="#d9ead3")
texto_sub2.place(relx=0.05, rely=0.5)
Coeficiente = IntVar()
Coeficiente_entrada = Entry(textvariable=Coeficiente,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Coeficiente_entrada.place(relx=0.58, rely=0.3, relwidth=0.35)
Termo_Constante = IntVar()
Termo_Constante_entrada = Entry(textvariable=Termo_Constante,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Termo_Constante_entrada.place(relx=0.58, rely=0.5, relwidth=0.35)
def limpar():
Termo_Constante_entrada.delete(0, END)
Coeficiente_entrada.delete(0, END)
resultado.set("")
def app():
a = Coeficiente.get()
b = Termo_Constante.get()
if a == 0:
if b == 0:
mensagem = "Infinitas soluções."
else:
mensagem = "Sem solução."
else:
x = -b / a
mensagem = f"Solução: x= {round(x,2)}"
resultado.set(mensagem)
but1 = Button(text="Calcular", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=app)
but1.place(relx=0.05, rely=0.65, 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.35, rely=0.65, 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.65, rely=0.65, relwidth=0.25, relheight=0.1)
resultado = StringVar()
resultado_texto = Label(textvariable=resultado,
font=("Arial", 12, "bold"), bg="#cfe2f3")
resultado_texto.place(relx=0.05, rely=0.8, relwidth=0.9,relheight=0.1)
root.mainloop()