from tkinter import *
root = Tk()
root.geometry("400x300")
root.resizable(0, 0)
root.config(bg="#265970")
root.title("Tranformar número positivo para negativo")
texto_sub1 = Label(text="Número:",
font=("Arial", "20", "bold"),bg="#265970",fg="#cfe0e8")
texto_sub1.place(relx=0.08, rely=0.2)
numero = DoubleVar()
numero_entrada = Entry(textvariable=numero,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
numero_entrada.place(relx=0.45, rely=0.22, relwidth=0.45)
def limpar():
numero_entrada.delete(0, END)
resultado.set("")
def app():
n = numero.get()
n_negativo = n*(-1)
mensagem = f"O número negativo de {n} é de {n_negativo}."
resultado.set(mensagem)
but1 = Button(text="Verificar", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=app)
but1.place(relx=0.05, rely=0.4, relwidth=0.25, relheight=0.15)
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.4, relwidth=0.25, relheight=0.15)
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.4, relwidth=0.25, relheight=0.15)
resultado = StringVar()
resultado_texto = Label(textvariable=resultado,
font=("Arial", 12, "bold"), bg="#cfe2f3")
resultado_texto.place(relx=0.05, rely=0.7, relwidth=0.9,relheight=0.15)
root.mainloop()