J
J
JRazor2014-07-13 17:53:01
Python
JRazor, 2014-07-13 17:53:01

PyQt4: slots and signals. How to pass a signal from Scrapy to PyQt?

Already asked a question, but ... and did not solve anything. I figured out the signals and slots, but I can’t transfer the information like that. Perhaps because of a different flow (which should not be an obstacle for signals), or perhaps because of crooked hands. I had the following code:

# -*- coding: utf-8 -*-
from PyQt4 import QtCore, QtGui

class SignalClass(QtCore.QObject):
    signal = QtCore.pyqtSignal(object)

    def __init__(self):
        QtCore.QObject.__init__(self)

    def send(self, text):
        self.signal.emit(text)

# Часть, которая будет выводить текст
@QtCore.pyqtSlot(object)
def output(text):
    print text

# Часть, которая будет передавать текст
bag = SignalClass()
bag.signal.connect(output)
bag.send(2) # Тут передаем значение функции output

That's how everything works. I distribute everything according to PyQt and Scrapy - nothing is transferred to QLabel. Any ideas?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Fedor Kichatov, 2015-03-28
@sozforex

If you have pyqt4 and twisted (used in scrapy) reactors (event loops) running in the same process (but, for example, in different threads), then these reactors will not release the GIL => the application will not work or will work in an unexpected way. There should not be more than one reactor in one Python process.
stackoverflow.com/questions/15087746/qt4reactor-sc...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question