Mundo em Python

Programa Tkinter

from tkinter import *
root=Tk()
root.title("APP")
root.geometry("500x300")
root.configure(bg="#42f5f5")
root.resizable(0,0)
def butaoclick1():
rv1 = variavel1.get()
rv2 = variavel2.get()
var = (rv2 - rv1)/rv1
varf = round((var*100),2)
if varf ==0:
mensagem = f'A variação de {rv1} e {rv2} é de 0.'
rvariacao1['fg'] = "blue"
elif varf<0:
mensagem = f'A variação de {rv1} e {rv2} é negativa.\n A variação é de {varf} %. '
rvariacao1['fg'] = "red"
else:
mensagem = f'A variação de {rv1} e {rv2} é positiva.\n A variação é de {varf} %. '
rvariacao1['fg'] = "green"
variacao1.set(mensagem) def limpar1():
entrada1.delete(0, END)
entrada2.delete(0, END) v1 = Label(text="Valor 1:",font=("Arial","12","bold"),
bg="#42f5f5",fg="black")
v1 .place(relx=0.25,rely=0.15)
variavel1 = DoubleVar()
entrada1 = Entry(textvariable=variavel1,justify='center',fg="green",bg="white")
entrada1.place(relx=0.45,rely=0.15)
v2 = Label(text="Valor 2:",font=("Arial","12","bold"),
bg="#42f5f5",fg="black")
v2 .place(relx=0.25,rely=0.4)
variavel2 = DoubleVar()
entrada2 = Entry(textvariable=variavel2,justify='center',fg="green",bg="white")
entrada2.place(relx=0.45,rely=0.4)
bt_calcular1 = Button( text="Calcular", bd=2, bg='#107db2',
fg='white', font=('verdana', 12, 'bold'),command=butaoclick1)
bt_calcular1.place(relx=0.35,rely=0.6, relwidth=0.15, relheight=0.1)
butlimpar1 = Button( text="Limpar", bd=2,
bg='#107db2', fg='white', font=('verdana', 12, 'bold'),
command=limpar1)
butlimpar1.place(relx=0.55, rely=0.6, relwidth=0.15, relheight=0.1)
variacao1 = StringVar()
rvariacao1=Label( textvariable=variacao1,font=("Arial",12,"bold"))
rvariacao1.place(relx=0.2,rely=0.8,relwidth=0.65)
root.mainloop()
0