PyQt emit signal with dict

Viewed 8396

I wanna to emit signal that is defined:

finished = pyqtSignal(dict)

# other place it's connected to function:
def finised(self, dict_result):

I call it self.finished.emit({"bk": {}}) and it works.
Now I call it with self.finished.emit({2: {}})and it don't work!!

Traceback (most recent call last): File "/home/sylwek/workspace/t2-pv/Manager.py", line 452, in run self.finished.emit({2: {}}) TypeError: TesterManager.finished[dict].emit(): argument 1 has unexpected type 'dict'

Is it normal? I can change {2: {}} to {'2': {}} but I would like to understand why and be sure there will be no other surprises!

I use PyQt 5.8.2-2 and python 3.6.1-1

EDIT (add working example):

from PyQt5 import QtCore, QtWidgets
from PyQt5.QtWidgets import QApplication


class Emiterer(QtCore.QThread):
    f = QtCore.pyqtSignal(dict)

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

    def run(self):
        self.f.emit({"2": {}})
        # self.f.emit({2: {}})  < == this don't work!


class Main(QtWidgets.QMainWindow):

    def __init__(self):
        super(Main, self).__init__()
        self.e = Emiterer()
        self.e.f.connect(self.finised)
        self.e.start()

    def finised(self, r_dict):
        print(r_dict)


if __name__ == '__main__':
    import sys
    app = QApplication(sys.argv)
    m = Main()
    m.show()
    sys.exit(app.exec_())
1 Answers
Related