<div dir="ltr"><div class="markdown-here-wrapper" style><p style="margin:1.2em 0px!important">Just a small tip, there’s a plug-in for chrome and firefox that does code highlighting in emails and google groups.</p>
<ul style="margin:1.2em 0px;padding-left:2em">
<li style="margin:0.5em 0px"><a href="http://markdown-here.com/">http://markdown-here.com/</a></li>
</ul>
<p style="margin:1.2em 0px!important">It looks like this:</p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code class="hljs language-python" style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline;background-color:rgb(248,248,248);white-space:pre;overflow:auto;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important;display:block;overflow-x:auto;padding:0.5em;color:rgb(51,51,51);background:rgb(248,248,248)"><span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">import</span> sys
<span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">from</span> PyQt4 <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">import</span> QtGui, QtCore

<span class="hljs-class"><span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">class</span> <span class="hljs-title" style="color:rgb(153,0,0);font-weight:bold;color:rgb(68,85,136);font-weight:bold">Example</span><span class="hljs-params">(QtGui.QWidget)</span>:</span>

    <span class="hljs-function"><span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">def</span> <span class="hljs-title" style="color:rgb(153,0,0);font-weight:bold">__init__</span><span class="hljs-params">(self)</span>:</span>
        super(Example, self).__init__()
        vbox = QtGui.QVBoxLayout()
        gb = QtGui.QGroupBox()

        button = QtGui.QPushButton(<span class="hljs-string" style="color:rgb(221,17,68)">"Hide"</span>)
        button.clicked.connect(self.toggle)

        vbox.addWidget(button)

        lbl = QtGui.QLabel(<span class="hljs-string" style="color:rgb(221,17,68)">"Test Label"</span>)
        vbox.addWidget(lbl)

        gbLayout = QtGui.QFormLayout()
        lbl1 = QtGui.QLabel(<span class="hljs-string" style="color:rgb(221,17,68)">"Hello"</span>, gb)
        gbLayout.addWidget(lbl1)

        le1 = QtGui.QLineEdit(gb)
        gbLayout.addWidget(le1)

        gb.setLayout(gbLayout)
        vbox.addWidget(gb)

        gb.setTitle(<span class="hljs-string" style="color:rgb(221,17,68)">"Test"</span>)
        self.setLayout(vbox)    

        self.show()

    <span class="hljs-function"><span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">def</span> <span class="hljs-title" style="color:rgb(153,0,0);font-weight:bold">toggle</span><span class="hljs-params">(self)</span>:</span>

       self.l = self.findChildren((QtGui.QGroupBox, QtGui.QLabel))
       <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">print</span> self.l
       <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">for</span> i <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">in</span> self.l:
         i.setVisible(<span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">not</span> i.isVisible())

<span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">if</span> __name__ == <span class="hljs-string" style="color:rgb(221,17,68)">'__main__'</span>:
    app = QtGui.QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())
</code></pre>
<div title="MDH:SnVzdCBhIHNtYWxsIHRpcCwgdGhlcmUncyBhIHBsdWctaW4gZm9yIGNocm9tZSBhbmQgZmlyZWZv
eCB0aGF0IGRvZXMgY29kZSBoaWdobGlnaHRpbmcgaW4gZW1haWxzIGFuZCBnb29nbGUgZ3JvdXBz
LjxkaXY+PGJyPjwvZGl2PjxkaXY+LSZuYnNwO2h0dHA6Ly9tYXJrZG93bi1oZXJlLmNvbS88L2Rp
dj48ZGl2P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Y7IGZvbnQtc2l6ZTogMTNweDsiPiZuYnNwOyAmbmJzcDsgc3lzLmV4aXQo
YXBwLmV4ZWNfKCkpPC9kaXY+PC9kaXY+PGRpdj5gYGA8L2Rpdj4=" style="height:0;font-size:0em;padding:0;margin:0">​</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 13 October 2014 20:12, Chris Wood <span dir="ltr"><<a href="mailto:c.c.wood@gmail.com" target="_blank">c.c.wood@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>I've found that where I have a QLabel as a child of my QWidget, and a QLabel which is a child of a QGroupBox which is a child of my QWidget, and I toggle the visibility of all the children of the QWidget via the click action of a button:</div><div><br></div><div>def toggleVis(self):</div><div>  self.results = findChildren((QLabel,QGroupBox))</div><div>  print self.results</div><div>  for w in self.results:</div><div>    w.setVisible(not w.isVisible())</div><div><br></div><div>After hiding the objects initially, and clicking the button again, the QLabel which is a child of the QGroupBox does not reappear, but all 3 objects are listed when self.results is printed (full code at end of email).  I expected this to work, since findChildren is recursive.  However, it *does* work if I reverse the list (for w in reverse(self.results)).  I get the same behaviour on both Unix (Fedora 20) and Windows 7. Is this documented? Perhaps a different way round this would be to specify names (I could probably use some regex to ensure I capture the objects I want), but wanted to make sure I hadn't missed something obvious from the docs first...</div><div><br></div><div>Cheers,</div><div>Chris</div><div><br></div><div>------</div><div><br></div><div><div>import sys</div><div>from PyQt4 import QtGui, QtCore</div><div><br></div><div>class Example(QtGui.QWidget):</div><div>    </div><div>    def __init__(self):</div><div>        super(Example, self).__init__()</div><div>        vbox = QtGui.QVBoxLayout()</div><div>        gb = QtGui.QGroupBox()</div><div>        </div><div>        button = QtGui.QPushButton("Hide")</div><div>        button.clicked.connect(self.toggle)</div><div><br></div><div>        vbox.addWidget(button)</div><div>        </div><div>        lbl = QtGui.QLabel("Test Label")</div><div>        vbox.addWidget(lbl)</div><div><br></div><div>        gbLayout = QtGui.QFormLayout()</div><div>        lbl1 = QtGui.QLabel("Hello", gb)</div><div>        gbLayout.addWidget(lbl1)</div><div>    </div><div>        le1 = QtGui.QLineEdit(gb)</div><div>        gbLayout.addWidget(le1)</div><div>    </div><div>        gb.setLayout(gbLayout)</div><div>        vbox.addWidget(gb)</div><div><br></div><div>        gb.setTitle("Test")</div><div>        self.setLayout(vbox)    </div><div>        </div><div>        self.show()</div><div>   </div><div>    def toggle(self):</div><div><br></div><div>       self.l = self.findChildren((QtGui.QGroupBox, QtGui.QLabel))</div><div>       print self.l</div><div>       for i in self.l:</div><div>         i.setVisible(not i.isVisible())</div><div><br></div><div>if __name__ == '__main__':</div><div>    app = QtGui.QApplication(sys.argv)</div><div>    ex = Example()</div><div>    sys.exit(app.exec_())</div></div><div><br></div></div>
<br>_______________________________________________<br>
PyQt mailing list    <a href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a><br>
<a href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt" target="_blank">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><font size="1"><b>Marcus Ottosson</b><br><a href="mailto:konstruktion@gmail.com" target="_blank">konstruktion@gmail.com</a></font><font size="1"><br></font></div>
</div>