[PyQt] How do you list the classes in say PyQt5.QtWidgets.pyd?
Luna Tuna
fruitfulapproach at gmail.com
Wed May 1 06:03:38 BST 2019
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20190430/7576c7ba/attachment.html>
-------------- next part --------------
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_())
More information about the PyQt
mailing list