S
S
Sergey2017-08-24 01:47:03
Python
Sergey, 2017-08-24 01:47:03

How to output data to pyqt5?

New to python! I put together a simple project and I want to display data in a window!

import sys, requests
from PyQt5.QtWidgets import QApplication, QWidget
from PyQt5.QtGui import QIcon

url = 'http://api.cryptonator.com/api/ticker/btc-rub'
response = requests.get(url)

class Example(QWidget):

    def __init__(self):
        super().__init__()

        self.initUI()


    def initUI(self):

        self.setGeometry(300, 300, 300, 220)

        self.show(response.json())


if __name__ == '__main__':

    app = QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())

I try to display in self.show, but I get the following error
TypeError: show(self): too many arguments

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
longclaps, 2017-08-24
@alekskondr

Strangely, the documentation says the same thing : the show method should be called with no arguments.
Of course, you should not pay attention to this: I want to display data in a window and I will!

S
sshmakov, 2017-09-04
@sshmakov

If purely for an example, then instead of QWidget, you can use QLabel or QTextEdit, respectively, then use self.setText("ffff") to show the text.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question