我有两个文件,sender.py 和 receiver.py
receiver.py
from Sender import sender
class receiver():
"""
receiver
"""
def __init__(self) -> None:
print(receiver.__name__)
self.rem = sender()
self.rem.comm.connect(self.txtReceived)
def txtReceived(self, txt):
print(self.txtReceived.__name__)
print(txt)
if __name__== "__main__":
receiver()
和发件人.py
from PySide6.QtCore import QObject, Signal
class sender(QObject):
"""
sender
"""
comm = Signal(str)
def __init__(self) -> None:
QObject.__init__(self)
print(sender.__name__)
self.__emitComm()
def __emitComm(self):
print(self.__emitComm.__name__)
self.comm.emit("TxT")
但是我不知道为什么,在receiver.py中,流代码没有到达txtReceived方法。
我的错误在哪里?
这是该死的简单代码,但我被卡住了。