How do you list the classes in say PyQt5.QtWidgets.pyd?

Luna Tuna <[email protected]>
Newsgroups gmane.comp.python.pyqt-pykde
Message-ID <CABhCPesjigNyrQ_CJ_Toh0sNFH8REqHw3WL+_DG-G125UdxYnA@mail.gmail.com>
Hello.

Attached is a simple 100 line example to show that I cannot (using the
usual python `inspect` methods) get the list of classes from a PyQt5 module.

I need the list of classes and to be able to use inspect on it.

Thanks.

-Fruitful Approach

_______________________________________________
PyQt mailing list    [email protected]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
pyqt_watermelon_builder.py (text/plain, 1.7 KB)
from pauseable_thread import PauseableThread
import PyQt5
import os
from importlib import import_module
import inspect

class PyQtWatermelonBuilder(PauseableThread):
    def __init__(self, out_dir=None, recurse=None):
        super().__init__()
        if out_dir is None:
            out_dir = 'watermelon'
        if recurse is None:
            recurse = True
        self._outputDir = out_dir
        self._inputDir = os.path.dirname(PyQt5.__file__)
        self._recursive = recurse
        
    def run(self):
        self.process_directory(self._inputDir)
        
    def process_directory(self, dirname):
        dir_list = os.listdir(dirname)
        for filename in dir_list:
            self.checkPause()
            full_name = os.path.join(dirname, filename)
            if os.path.isfile(os.path.join(dirname, filename)):
                name, ext = os.path.splitext(filename)
                if ext == '.pyd':
                    module = import_module('PyQt5.QtWidgets')
                    members = inspect.getmembers(module)
                    for x in members:
                        if inspect.isabstract(x):
                            print('hi')
                        elif inspect.isclass(x):
                            print(inspect.getclasstree(classes))
                            break
            else:
                if self._recursive:
                    self.process_directory(dirname=full_name)
            
            breakpoint = 1
                
    
    
if __name__ == '__main__':
    from PyQt5.QtWidgets import QApplication
    import sys
    
    app = QApplication([])
    
    builder = PyQtWatermelonBuilder(out_dir='test_output')
    builder.start()
    
    sys.exit(app.exec_())
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.