Hello and thank you for all your work, this website is a great tool to learn pyside2.
I’me having an issue with " Animating custom widgets with QPropertyAnimation" example.
It doesn’t work for me with pyside2: properties are acting strangely.
I’ve been able to make the not animated toggle widget work by make these small changes.
In the __init__ i’ve setted the two properties to 0 (otherwise it breaks later when the code tries to access them):
self.handle_position = 0
self.pulse_radius = 0
In the handle position i’ve changed self._handle_position to self.handle_position :
Hi @Barsotti welcome to the forum & thanks for the feedback!
I remember when we were writing this tutorial having some problems with earlier versions of PySide2 – can you check which version you currently have installed? I’ve got 5.15.2 currently and can’t see any problems when running the example code.
fyi by replacing self._handle_position with self.handle_position you’re overwriting the Qt property (defined using the @Property(float) decorator). This will disable all the property behavior including animations etc.
I was referring to this line in your first comment where the value was being set onto handle_position – this will override the property. I see that’s fixed in your second example, so no problem.
self.handle_position = 0
You’re right, if you’re reading from it in your own code it will make no difference which you use.
i’m using pyside2 5.13.2.
I think that explains the problem – if I remember correctly the bug was fixed in 5.15.2. Are you able to update to that to test it out?
Unfortunately i’m using a conda env Python 3.6 and pyside2 5.13.2 is the last version available on anaconda. I’ve had many issues trying to install it with pip, so I will stick to this version for now.