Is there any possibility to create signals at runtime when needed?
I'm doing something like this in a function:
class WSBaseConnector(QObject)
def __init__(self) -> None:
super(QObject, self).__init__()
self._orderBookListeners: Dict[str, pyqtSignal[OrderBookData]] = {}
def registerOrderBookListener(self, market: str, listener: Callable[[OrderBookData], None], loop: AbstractEventLoop) -> None:
try:
signal = self._orderBookListeners[market]
except KeyError:
signal = pyqtSignal(OrderBookData)
signal.connect(listener)
self._orderBookListeners[market] = signal
else:
signal.connect(listener)
As you can see, I have a dict that stores str, pyqtSignal pairs. When I try to connect the signal to the listener I get the error:
'PyQt5.QtCore.pyqtSignal' object has no attribute 'connect'
Is it not possible to create pyqtSignals at runtime without been class vars?
Cheers.
FunkyDynamicSignals().example
usage after example has been constructed in another instance. Anything is possible with Python though... :) – Lavinia