AnimationGroupMixin
Base classes
Subclasses
⋔ Inheritance diagram
graph TD
1473299826736["core.AnimationGroupMixin"]
1473299791600["core.AbstractAnimationMixin"]
1473299815024["core.ObjectMixin"]
140713234304496["builtins.object"]
1473299791600 --> 1473299826736
1473299815024 --> 1473299791600
140713234304496 --> 1473299815024
🛈 DocStrings
Bases: AbstractAnimationMixin
Source code in prettyqt\core\animationgroup.py
| class AnimationGroupMixin(core.AbstractAnimationMixin):
@overload
def __getitem__(self, index: int) -> core.QAbstractAnimation:
...
@overload
def __getitem__(
self, index: slice
) -> listdelegators.ListDelegator[core.QAbstractAnimation]:
...
def __getitem__(self, index: int | slice):
count = self.animationCount()
match index:
case int():
if index < 0:
index = count + index
if index >= count:
raise IndexError(index)
anim = self.animationAt(index)
if anim is None:
raise KeyError(index)
return anim
case slice():
stop = index.stop or count
rng = range(index.start or 0, stop, index.step or 1)
anims = [self.animationAt(i) for i in rng]
return listdelegators.ListDelegator(anims)
case _:
raise TypeError(index)
def __setitem__(self, index: int, value: core.QAbstractAnimation):
if not (0 <= index < self.animationCount()):
raise KeyError(index)
self.takeAnimation(index)
self.insertAnimation(index, value)
def __len__(self):
return self.animationCount()
def __delitem__(self, index: int):
if not (0 <= index < self.animationCount()):
raise KeyError(index)
self.takeAnimation(index)
def __add__(self, other: core.QAbstractAnimation):
self.addAnimation(other)
return self
def targetObject(self) -> widgets.QWidget:
"""Return shared targetObject if existing."""
targets = [
anim.targetObject()
for i in range(self.animationCount())
if isinstance((anim := self.animationAt(i)), core.QPropertyAnimation)
]
if len(targets) != self.animationCount() or len(set(targets)) != 1:
raise RuntimeError("Could not find shared targetObject for all animations.")
return targets[0]
def add_property_animation(self, obj: Callable) -> core.PropertyAnimation:
anim = core.PropertyAnimation()
anim.apply_to(obj)
self.addAnimation(anim)
return anim
|
targetObject() -> widgets.QWidget
Return shared targetObject if existing.
Source code in prettyqt\core\animationgroup.py
| def targetObject(self) -> widgets.QWidget:
"""Return shared targetObject if existing."""
targets = [
anim.targetObject()
for i in range(self.animationCount())
if isinstance((anim := self.animationAt(i)), core.QPropertyAnimation)
]
if len(targets) != self.animationCount() or len(set(targets)) != 1:
raise RuntimeError("Could not find shared targetObject for all animations.")
return targets[0]
|