Created
March 28, 2017 01:10
-
-
Save sametz/a4f2cc8557e73b32fd45d7c66d16fb66 to your computer and use it in GitHub Desktop.
Determine list of parents of a PyQt5 object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def test_child_parent_map(self): | |
va_widget_fetch = self.ui.findChild(QDoubleSpinBox, 'va') # look up a widget by objectName | |
current_widget = va_widget_fetch | |
end = False | |
while not end: | |
try: | |
print('Widget ', current_widget.objectName(), ' has parent ', | |
current_widget.parent().objectName()) | |
current_widget = current_widget.parent() | |
except: | |
print('The parent of', current_widget.objectName(), | |
'is of type', type(current_widget.parent())) | |
print('No more parents.') | |
end = True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment