Python Forum

Full Version: BTC Pricce and PyQt5
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I am a beginner in Python and I ran into some issues.

I want to creaate an App that shows me the real time Bitcoin proce.
I managed to getch tje data and print it to the terminal. But I want to see it in a PyQt5 App.
I made the PyQt5 window (GUI.ui), but I can't get them to work together.

So I need some help joining them together.
I don't lmow why, but I can't upload the HUI.ui file. But is just has a label named 'lblUSDPrice'

This is what I would like :
1. Update the lbale in real time.
2. The format I used, I'd like to keep.

I hope womeone can get me the help I need...

Thnx !!!

from PyQt5.QtWidgets import QMainWindow, QApplication, QLabel, QPushButton
from PyQt5 import uic
import sys, time, ccxt
from babel.numbers import format_currency
import json
import websocket


class UI(QMainWindow):
    def __init__(self):
        super(UI, self).__init__()

        # Load UI File
        uic.loadUi("GUI.ui", self)

        # Set USD Label
        # self.lblUSDPrice = self.findChild(QLabel, "lblUSDPrice")
        # self.lblUSDPrice.setText(usd)

        # Show the App
        self.show()

        def on_open(ws):
            print("Open...")

        def dollars(ws, message):
            usd = json.loads(message)
            usd = str(usd['c'])
            usd = (format_currency(usd, '', locale='nl_NL'))
            print(usd)

        socket = f'wss://stream.binance.com:9443/ws/btcusdt@ticker'
        ws = websocket.WebSocketApp(socket, on_open=on_open, on_message=dollars)
        ws.run_forever()


app = QApplication(sys.argv)
UIWindow = UI()
app.exec_()
Output:
Open...  43.066,35  43.068,04  43.068,04  43.068,05  43.068,05
Error:
Until here it goes like I want, but when I add the label (I 'hashtagged' them out for now), I get nothing. It even doesn't load the Gui...
Maybe I am doing this the wring way all together?