python - Signal not connecting to a method -


i working sockets. when receive info server handle method listen in thread. want pop windows here, use signals.

the problem signal not trigger function. here working example:

class client(qtcore.qobject):     signal = qtcore.pyqtsignal()      def __init__(self):         super(client, self).__init__()         self.thread_wait_server = threading.thread(target=self.wait_server)         self.thread_wait_server.daemon = true         self.thread_wait_server.start()      def wait_server(self):         print('waiting')         self.signal.emit()         print("'signal emited")   class main:     def do(self):         print("'do' starts")         self.launch()         time.sleep(2)         print("'do' ends")      def launch(self):         print("'launch' starts")         self.client = client()         self.client.signal.connect(self.tester)         print("'launch' ends")      def tester(self):         print("tester fired!!")  m = main() m.do() 

tester function never triggered.

the problem code that, emitting signal before connecting slot! add 2 print statements this:

print("connecting signal") self.client.signal.connect(self.tester) print("signal connected") 

you notice signal gets emitted before gets connected! that's why slot not triggering.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

android - CollapsingToolbarLayout: position the ExpandedText programmatically -

Listeners to visualise results of load test in JMeter -