Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've done something similar to this but on a less generic and more granular scale. I created a context manager to temporarily disconnect slots. This way it's clear that you disable certain slots within a block of code then you re-connect them and can emit anything that you missed in between.</p> <p>The source is <a href="https://gist.github.com/durden/5060373" rel="nofollow">here</a> and I pasted the snippet below. This might not be quite what you want, but it was useful for me in a similar scenario. I wanted to do something that could emit of 'intermediate' signals where the 'intermediate' changes didn't matter in the long run. So, with this context manager I can disable the noisy signals and then just emit it once afterwards if needed. This allows you to avoid a lot of intermediate state changes.</p> <p>A good example is setting <a href="http://pyqt.sourceforge.net/Docs/PyQt4/qcheckbox.html" rel="nofollow">PyQt QCheckboxes</a> in a loop. You could call <code>checkbox.setChecked()</code> in a loop but you would emit a bunch of signals for each checkbox. However, you could use the context manager below to disable any slots for the <code>stateChanged</code> signal and the emit the <code>stateChanged</code> signal once yourself with the 'final' result.</p> <pre><code>from contextlib import contextmanager @contextmanager def slot_disconnected(signal, slot): """ Create context to perform operations with given slot disconnected from given signal and automatically connected afterwards. usage: with slot_disconnected(chkbox.stateChanged, self._stateChanged): foo() bar() """ signal.disconnect(slot) yield signal.connect(slot) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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