-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
36 lines (23 loc) · 975 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import requests
from tkinter import *
def pegar_cotacoes():
requisicao = requests.get("https://economia.awesomeapi.com.br/last/USD-BRL,EUR-BRL,BTC-BRL")
requisicao_dic = requisicao.json()
cotacao_dolar = requisicao_dic['USDBRL']['bid']
cotacao_euro = requisicao_dic['EURBRL']['bid']
cotacao_btc = requisicao_dic['BTCBRL']['bid']
texto = f'''
Dólar: {cotacao_dolar}
Euro: {cotacao_euro}
BTC: {cotacao_btc}'''
texto_cotacoes["text"] = texto
janela = Tk()
janela.title("Cotação atual das moedas")
janela.geometry("400x400")
texto_orientacao = Label(janela, text="Clique no botão para ver as cotações das moedas")
texto_orientacao.grid(column=0, row=0, padx=10, pady=10)
botao = Button(janela, text= "Buscar cotações Dólar/Euro/BTC", command=pegar_cotacoes)
botao.grid(column=0, row=1, padx=10, pady=10)
texto_cotacoes = Label(janela, text="")
texto_cotacoes.grid(column=0, row=2, padx=10, pady=10 )
janela.mainloop()