0

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 .

  • You should check `after()` method. There are numerous questions/answers in SO about that. – Lafexlos Jul 25 '17 at 07:44
  • I see now, didn't hear of it yet, new world of possibilities opens, thx. – Marcel Giezen Jul 25 '17 at 10:42
  • got it working with: def update_clock(self): now = polo.returnTicker()['BTC_ARDR']['last'] self.label.configure(text=now) self.root.after(1000, self.update_clock) – Marcel Giezen Jul 30 '17 at 12:35
  • 1
    Glad you made it work. By the way, you can add your own answer below instead of comment. That way, if someone else sees this question would find its answer easily. – Lafexlos Jul 30 '17 at 19:05

0 Answers0