mardi 28 janvier 2020

Pyside2, How to avoid .parent().parent().parent().parent()

So I have a simple pyside2 app where I want a button to update a counter widget.

The button has been subclassed and has a function that calls the increment function of the counter widget.

Currently call looks like this

self.parent().parent().parent().parent().counter_widget.increment()

This is pretty ugly. How should I make this call between widgets that are are so distant in the class hierarchy.

Aucun commentaire:

Enregistrer un commentaire