Mundo em Python

Acrescentar uma percentagem

from tkinter import *
root = Tk()
root.geometry("400x400")
root.resizable(0, 0)
root.config(bg="#08779c")
root.title("Acrescentar uma percentagem")
def app():
per = percentagem.get()
v = valor_acrescentado.get()
perpp = per/100
t = v*perpp
tarr = round(t, 2)
mensagem = f"Valor a Acrescentar: {tarr}.\nValor Total: {tarr+v}."
resultado.set(mensagem)
def limpar():
percentagem_entrada.delete(0, END)
valor_acrescentado_entrada.delete(0, END)
resultado.set("")
titulo = Label(text="Acrescentar uma percentagem",
font=("Arial", "19", "bold"),bg="#08779c",fg="#d1e0e6")
titulo.place(relx=0.05, rely=0.05)
texto_sub1 = Label(text="Valor Inicial:",
font=("Arial", "15", "bold"),bg="#08779c",fg="#d1e0e6")
texto_sub1.place(relx=0.2, rely=0.25) texto_sub2=Label(text="Percentagem(%):",
font=("Arial", "15", "bold"),bg="#08779c",fg="#d1e0e6")
texto_sub2.place(relx=0.13, rely=0.45)
percentagem = DoubleVar()
percentagem_entrada = Entry(textvariable=percentagem,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
percentagem_entrada.place(relx=0.55, rely=0.45, relwidth=0.4) valor_acrescentado = DoubleVar()
valor_acrescentado_entrada = Entry(textvariable=valor_acrescentado,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
valor_acrescentado_entrada.place(relx=0.55, rely=0.25, relwidth=0.4) but1 = Button(text="Calcular", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=app)
but1.place(relx=0.08, 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.38, 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.68, 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.15)
root.mainloop()
0