Mundo em Python

Aumento da Portagem 2025

from tkinter import *

root = Tk()
root.geometry("600x300")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Aumento da Portagem 2025") titulo = Label(text="Aumento da Portagem 2025",
font=("Arial", "28", "bold"), bg="#103030", fg="#49e3e3")
titulo.place(relx=0.08, rely=0.05) texto_sub1 = Label(text="Preço de 2024 :",
font=("Arial", "20", "bold"), bg="#103030", fg="#49e3e3")
texto_sub1.place(relx=0.2, rely=0.35) Preço = StringVar()
Preço_entrada = Entry(textvariable=Preço,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Preço_entrada.place(relx=0.58, rely=0.36, relwidth=0.35) def limpar():
Preço_entrada.delete(0, END)
resultado_texto.config(text="") def app():
try:
p = float(Preço.get())
t = 2.21 / 100
p_novo = (p * t) + p
aumento = (p * t)
variacao = (p_novo - p) / p mensagem = f"O preço para 2025: {round(p_novo, 2)} " \
f"€\n Aumento para 2025: {round(aumento, 2)}" \
f" €\n Variação do Preço: {round(variacao * 100, 2)}% "
resultado_texto.config(text=mensagem) except ValueError:
resultado_texto.config(text="Valor digitado inválido.") # Vincula o pressionar da tecla Enter à função app()
root.bind('<Return>', lambda event: app()) but1 = Button(text="Calcular", 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=limpar)
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) resultado_texto = Label(text="",
font=("Arial", 12, "bold"), bg="#cfe2f3")
resultado_texto.place(relx=0.05, rely=0.7, relwidth=0.9, relheight=0.25) root.mainloop()
0