Advertisement
StSav012

PySide6 subclasses missing

Oct 16th, 2024 (edited)
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.08 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2.  
  3. # https://bugreports.qt.io/browse/PYSIDE-2898
  4.  
  5. _init = set(globals())
  6. # uncomment one or more of the three following lines:
  7. # from PySide6.QtCore import __spec__  # or whatever else
  8. # from PySide6.QtGui import __spec__  # or whatever else
  9. # from PySide6.QtWidgets import __spec__  # or whatever else
  10.  
  11. from PySide6.QtCore import *
  12. from PySide6.QtGui import *
  13. from PySide6.QtWidgets import *
  14. _imported = set(globals()) - _init
  15.  
  16.  
  17. def subclasses():
  18.     import enum
  19.  
  20.     for class_name in _imported:
  21.         if class_name[1].isupper() and isinstance((cls:=globals()[class_name]), type):
  22.             for subclass_name in cls.__dict__:
  23.                 if subclass_name[0].isupper():
  24.                     if isinstance((subclass:=getattr(cls, subclass_name)), type) and enum.Enum not in subclass.__mro__:
  25.                         # print(class_name, subclass_name, sep='.')
  26.                         yield class_name, subclass_name
  27.  
  28.  
  29. print(sum(1 for _ in subclasses()), "subclasses found")
  30. # list the classes
  31. # print(*map('.'.join, subclasses()), sep='\n')
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement