Mundo em Python

Taxa de Câmbio Real

from tkinter import *
root = Tk()
root.geometry("500x450")
root.resizable(0, 0)
root.config(bg="#0b2a9c")
root.title("Taxa de Câmbio Real")
titulo = Label(text="Taxa de Câmbio Real",
font=("Arial", "27", "bold"),bg="#0b2a9c",fg="#d9ead3")
titulo.place(relx=0.05, rely=0.05)
texto_sub1 = Label(text="Taxa de Câmbio Nominal:",
font=("Arial", "15", "bold"),bg="#0b2a9c",fg="#d9ead3")
texto_sub1.place(relx=0.13, rely=0.25) texto_sub2 = Label(text="Índice de Preços Domésticos:",
font=("Arial", "15", "bold"),bg="#0b2a9c",fg="#d9ead3")
texto_sub2.place(relx=0.05, rely=0.4)
texto_sub3 = Label(text="Índice de Preços Externos:",
font=("Arial", "15", "bold"),bg="#0b2a9c",fg="#d9ead3")
texto_sub3.place(relx=0.12, rely=0.55)
Taxa_Câmbio_Nominal = DoubleVar()
Taxa_Câmbio_Nominal_entrada = Entry(textvariable=Taxa_Câmbio_Nominal,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Taxa_Câmbio_Nominal_entrada.place(relx=0.65, rely=0.25, relwidth=0.3)
Índice_Preços_Domésticos = DoubleVar()
Índice_Preços_Domésticos_entrada = Entry(textvariable=Índice_Preços_Domésticos,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Índice_Preços_Domésticos_entrada.place(relx=0.65, rely=0.4, relwidth=0.3) Índice_Preços_Externos = DoubleVar()
Índice_Preços_Externos_entrada = Entry(textvariable=Índice_Preços_Externos,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Índice_Preços_Externos_entrada.place(relx=0.65, rely=0.55, relwidth=0.3)
def limpar():
Índice_Preços_Externos_entrada.delete(0, END)
Índice_Preços_Domésticos_entrada.delete(0, END)
Taxa_Câmbio_Nominal_entrada.delete(0, END)
resultado.set("") def app():
ipe = Índice_Preços_Externos.get()
ipd = Índice_Preços_Domésticos.get()
tcn = Taxa_Câmbio_Nominal.get()
TaxadeCâmbioReal = tcn * (ipd/ipe)
mensagem = f' Taxa de Câmbio Real: {round(TaxadeCâmbioReal,2)}.'
resultado.set(mensagem)
but1 = Button(text="Calcular", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=app)
but1.place(relx=0.05, 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.35, 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.65, 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.1)
root.mainloop()
0