Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Check out this <a href="https://stackoverflow.com/questions/569650/how-to-keep-track-of-thread-progress-in-python-without-freezing-the-pyqt-gui">question I asked</a> a while back. There is a code example that might help you figure out what you need to do.</p> <p>What you said about registering your signal makes me think of this code (from the aforementioned question):</p> <pre><code>class ProcessingThread(threading.Thread, QtCore.QObject): __pyqtSignals__ = ( "progressUpdated(str)", "resultsReady(str)") </code></pre> <p>I'm passing strings in my example, but you should be able to replace <code>str</code> with <code>list</code>.</p> <p>If it turns out that you can't pass mutable objects, you can handle your results the way I do in my example (i.e. set a <code>results</code> variable in the thread, tell the main thread that they are ready, and have the main thread "pick them up"). </p> <p><strong>Update:</strong></p> <p>You get the message <code>QObject::connect: Cannot queue arguments of type 'statuses'</code> because you need to define the <em>type</em> of argument that you will pass when you emit your signal. The type you want to pass is <code>list</code> not <code>statuses</code>. </p> <p>When you connect your signal it should look like this:</p> <pre><code>QtCore.QObject.connect(self.twit_in, QtCore.SIGNAL("newStatuses(list)"), self.update_tweet_list) </code></pre> <p>When you emit your signal it should look like this:</p> <pre><code>self.emit(SIGNAL("newStatuses(list)"), statuses) </code></pre> <p>given that <code>statuses</code> is a list. Note that you may want to emit a deep copy of your list depending on your situation.</p> <p><strong>Update 2:</strong></p> <p>Ok, using <code>list</code> as the type is not correct. From the PyQt4 help reference:</p> <blockquote> <h2>PyQt Signals and Qt Signals</h2> <p>Qt signals are statically defined as part of a C++ class. They are referenced using the <code>QtCore.SIGNAL()</code> function. This method takes a single string argument that is the name of the signal and its C++ signature. For example::</p> <pre><code>QtCore.SIGNAL("finished(int)") </code></pre> <p>The returned value is normally passed to the <code>QtCore.QObject.connect()</code> method.</p> <p>PyQt allows new signals to be defined dynamically. The act of emitting a PyQt signal implicitly defines it. PyQt v4 signals are also referenced using the <code>QtCore.SIGNAL()</code> function.</p> <h2>The <code>PyQt_PyObject</code> Signal Argument Type</h2> <p>It is possible to pass any Python object as a signal argument by specifying <code>PyQt_PyObject</code> as the type of the argument in the signature. For example::</p> <pre><code>QtCore.SIGNAL("finished(PyQt_PyObject)") </code></pre> <p>While this would normally be used for passing objects like lists and dictionaries as signal arguments, it can be used for any Python type. Its advantage when passing, for example, an integer is that the normal conversions from a Python object to a C++ integer and back again are not required.</p> <p>The reference count of the object being passed is maintained automatically. There is no need for the emitter of a signal to keep a reference to the object after the call to <code>QtCore.QObject.emit()</code>, even if a connection is queued.</p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload