Python 3 TKinter api data feed

359 Views Asked by At

Making a GUI with Python 3 / TKinter.

Need import poloniex

I have a ticker from Poloniex which shows the last price and the highest bid. The problem is when i run the price ticker app outside Tkinter app, it runs fine and updates (sec)

Used very small apps to see if things work.

When i try to implement the app in a Tkinter app i doesn't want to update, and gives a error.

How can i make the app showing updated data from the ticker


works fine

from poloniex import Poloniex
import time

polo = Poloniex()
starttime=time.time()

while True:

    ticker = polo.returnTicker()['BTC_ARDR'] ['last']
    highBid = polo.returnTicker()['BTC_ARDR'] ['highestBid']

    print("Dit is de laatste prijs in BTC-ARDR op Poloniex :", ticker )
    print()
    print (" Dit is de hoogste bieding in BTC-ARDR op Poloniex: ", 
    highBid)
    print("-----------------------------------------------------------------
    ------------")

    time.sleep(5)

Code i need to run, i removed the time sleep code, because it din't work, what ever i tried. I need the feed every 2 sec showing updated in the tkinter app.

from tkinter import *
from poloniex import Poloniex
import time
import numpy as np

polo = Poloniex()

master = Tk()
master.geometry("480x360")


ticker = polo.returnTicker()['BTC_ARDR'] ['last']
highBid = polo.returnTicker()['BTC_ARDR'] ['highestBid']



Label(master, text= ticker * 100000000 ).grid(row=2)
Label(master, text= highBid ).grid(row=3)

Label(master, text= "LastPrice").grid(row=0)
Label(master, text="Last Name").grid(row=1)

e1 = Entry(master)
e2 = Entry(master)


e1.grid(row=0, column=1)
e2.grid(row=1, column=1)

mainloop( )

answer def update_clock(self): now = polo.returnTicker()['BTC_ARDR']['last'] self.label.configure(text=now) self.root.after(1000, self.update_clock)

now = used in a label, updates price every sec .

0

There are 0 best solutions below