app: Refactor get_all_objects.
This commit is contained in:
parent
698e4049d3
commit
1ce1c91d69
@ -465,17 +465,17 @@ class Application(QApplication):
|
|||||||
lines.append(repr(w))
|
lines.append(repr(w))
|
||||||
return '\n'.join(lines)
|
return '\n'.join(lines)
|
||||||
|
|
||||||
def get_all_objects(self, obj=None, depth=0, lines=None):
|
def _get_pyqt_objects(self, lines, obj, depth=0):
|
||||||
"""Get all children of an object recursively as a string."""
|
"""Recursive method for get_all_objects to get Qt objects."""
|
||||||
if lines is None:
|
|
||||||
lines = []
|
|
||||||
if obj is None:
|
|
||||||
obj = self
|
|
||||||
for kid in obj.findChildren(QObject):
|
for kid in obj.findChildren(QObject):
|
||||||
lines.append(' ' * depth + repr(kid))
|
lines.append(' ' * depth + repr(kid))
|
||||||
self.get_all_objects(kid, depth + 1, lines)
|
self._get_pyqt_objects(lines, kid, depth + 1)
|
||||||
if depth == 0:
|
|
||||||
lines.insert(0, '{} objects:'.format(len(lines)))
|
def get_all_objects(self):
|
||||||
|
"""Get all children of an object recursively as a string."""
|
||||||
|
lines = []
|
||||||
|
self._get_pyqt_objects(lines, self)
|
||||||
|
lines.insert(0, '{} objects:'.format(len(lines)))
|
||||||
return '\n'.join(lines)
|
return '\n'.join(lines)
|
||||||
|
|
||||||
def _recover_pages(self):
|
def _recover_pages(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user