<div dir="ltr"><div class="gmail_default" style="font-family:tahoma,sans-serif">Sorry if this turns out to be a general question about Python's <span style="font-family:monospace,monospace">instanceof()</span> rather than specifically PyQt.....</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">For debugging leaks (in a simple fashion) I am walking <span style="font-family:monospace,monospace">QtWidgets.QApplication.allWidgets()</span> looking at those whose <span style="font-family:monospace,monospace">parent() is None</span>.</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">I come across one I wish to <tt><font face="monospace, monospace">ignore</font></tt>.  PyCharm debugger shows its class as <span style="font-family:monospace,monospace">__main__.Main</span>.  My code has:</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="margin-left:40px"><span style="font-family:monospace,monospace">class Main(QtWidgets.QMainWindow):</span></div><div class="gmail_default" style="margin-left:40px"><span style="font-family:monospace,monospace">    ...</span></div><div class="gmail_default" style="margin-left:40px"><span style="font-family:monospace,monospace"><br></span></div><div class="gmail_default" style="font-family:tahoma,sans-serif"><div style="margin-left:40px"><span style="font-family:monospace,monospace">if __name__ == '__main__':</span><br><span style="font-family:monospace,monospace">    mainWindow = Main()</span><br></div><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">So in my checker I try:</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="margin-left:40px"><span style="font-family:monospace,monospace">from main.py import Main</span></div><div class="gmail_default" style="margin-left:40px"><span style="font-family:monospace,monospace">if isinstance(widget, Main): ...</span></div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">But this returns <span style="font-family:monospace,monospace">False</span> on the widget.  I discovered I can just check instead for <span style="font-family:monospace,monospace">isinstance(widget, QtWidgets.QMainWindow)</span>, so I'm OK and that's better anyway.</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">But I don't understand why it is not an instance of my <span style="font-family:monospace,monospace">Main</span> given that is derived from <span style="font-family:monospace,monospace">QtWidgets.QMainWindow</span>?  Could someone patiently enlighten me?<br clear="all"></div><br>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><span style="font-family:tahoma,sans-serif">Kindest,</span></div><div><span style="font-family:tahoma,sans-serif">Jonathan</span></div></div></div></div></div>
</div>