[PyQt] Not understanding instanceof() in this situation
jnbarchan at gmail.com
Tue Jul 17 16:45:00 BST 2018
Sorry if this turns out to be a general question about Python's instanceof()
rather than specifically PyQt.....
For debugging leaks (in a simple fashion) I am walking
QtWidgets.QApplication.allWidgets() looking at those whose parent() is None.
I come across one I wish to ignore. PyCharm debugger shows its class as
__main__.Main. My code has:
if __name__ == '__main__':
mainWindow = Main()
So in my checker I try:
from main.py import Main
if isinstance(widget, Main): ...
But this returns False on the widget. I discovered I can just check
instead for isinstance(widget, QtWidgets.QMainWindow), so I'm OK and that's
But I don't understand why it is not an instance of my Main given that is
derived from QtWidgets.QMainWindow? Could someone patiently enlighten me?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the PyQt