Python Forum
[PyQt] BTC Pricce and PyQt5
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyQt] BTC Pricce and PyQt5
#1
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?
Larz60+ write Mar-22-2022, 03:30 PM:
rather than using links:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Huge code problems (buttons(PyQt5),PyQt5 Threads, Windows etc) ZenWoR 0 2,858 Apr-06-2019, 11:15 PM
Last Post: ZenWoR

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020