Mundo em Python

Vértice de uma parábola (usando Tkinter)

from tkinter import *

root = Tk()
root.geometry("500x500")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Vértice de uma parábola") titulo = Label(text="Vértice de uma Parábola",
font=("Arial", "28", "bold"), bg="#103030", fg="#49e3e3")
titulo.place(relx=0.08, rely=0.05) texto_sub1 = Label(text="A:",
font=("Arial", "18", "bold"), bg="#103030", fg="#49e3e3")
texto_sub1.place(relx=0.25, rely=0.2) texto_sub2 = Label(text="B:",
font=("Arial", "18", "bold"), bg="#103030", fg="#49e3e3")
texto_sub2.place(relx=0.25, rely=0.35) texto_sub3 = Label(text="C:",
font=("Arial", "18", "bold"), bg="#103030", fg="#49e3e3")
texto_sub3.place(relx=0.25, rely=0.5) A = StringVar()
A_entrada = Entry(textvariable=A,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
A_entrada.place(relx=0.45, rely=0.2, relwidth=0.45)
A_entrada.focus()
B = StringVar()
B_entrada = Entry(textvariable=B,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
B_entrada.place(relx=0.45, rely=0.35, relwidth=0.45) C = StringVar()
C_entrada = Entry(textvariable=C,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
C_entrada.place(relx=0.45, rely=0.5, relwidth=0.45) def limpar():
A_entrada.delete(0, END)
B_entrada.delete(0, END)
C_entrada.delete(0, END)
resultado_texto.config("")
def app():
try:
a = int(A.get())
b = int(B.get())
c = int(C.get())
x_v = -b / (2 * a)
y_v = a * x_v ** 2 + b * x_v + c
resultado_texto.config(text=f"As coordenadas do vértice da parábola são: {x_v}, {y_v}")
except ValueError:
resultado_texto.config(text="Digitação errada") but1 = Button(text="Calcular", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=app)
but1.place(relx=0.1, 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.4, 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.7, rely=0.65, relwidth=0.25, relheight=0.1) resultado_texto = Label(text="",
font=("Arial", 12, "bold"), bg="#cfe2f3")
resultado_texto.place(relx=0.05, rely=0.8, relwidth=0.9, relheight=0.15) root.mainloop()
0