Hi I have some simple code here. https://pastebin.com/97uuqKQD
I would simply like to add something like this, to the button function, so while the root window is open the datetime and exrates are constantly regotten from the xe website and displayed.
amount = '1'
def continuousUpdate():
while amount == '0':
results()
def results():
#Get xe data put to labels etc here
btnConvert = tk.Button(root, text="Get Exchange Rates",command=continuousUpdate).place(x=5,y=102)
Once I input the two exrates and they then display on there respective labels I would like the program to continuously grab the data from xe over and over again.
Like this code here which runs in IPython no problems,
import requests
from bs4 import BeautifulSoup
from datetime import datetime
amount = '1'
while amount != '0':
t = datetime.utcnow()
url1 = "http://www.xe.com/currencyconverter/convert/" + "?Amount=" + amount + "&From=" + cur1 + "&To=" + cur2
url2 = "http://www.xe.com/currencyconverter/convert/" + "?Amount=" + amount + "&From=" + cur2 + "&To=" + cur1
#url = "http://www.xe.com/currencycharts/" + "?from=" + cur1 + "&to=" + cur2
html_code1 = requests.get(url1).text
html_code2 = requests.get(url2).text
soup1 = BeautifulSoup(html_code1, 'html.parser')
soup2 = BeautifulSoup(html_code2, 'html.parser')
i = i + 1
rate1 = soup1.find('span', {'class', 'uccResultAmount'})
rate2 = soup2.find('span', {'class', 'uccResultAmount'})
print ('#',i, t,'\n', cur1,'-',cur2, rate1.contents[0], cur2,'-',cur1, rate2.contents[0], '\n')
I thought I would just be able to throw the entire results function into a while loop function then simply call that function but no luck any help would be appreciated.???