AnimationGroupMixin
Sub classes
Base classes
| Name |
Children |
Inherits |
AbstractAnimationMixin prettyqt.core.abstractanimation The base of all animations. |
|
|
object builtins The base class of the class hierarchy. |
- type
async_generatorbytearray_iterator- bytearray
bytes_iterator- bytes
builtin_function_or_methodcallable_iteratorPyCapsulecellclassmethod_descriptor- ...
|
|
⋔ Inheritance diagram
graph TD
3440267878["core.AnimationGroupMixin"]
565069530["core.AbstractAnimationMixin"]
3227531497["core.ObjectMixin"]
2751680898["builtins.object"]
565069530 --> 3440267878
3227531497 --> 565069530
2751680898 --> 3227531497
2751680898 --> 565069530
2751680898 --> 3440267878
🛈 DocStrings
Bases: AbstractAnimationMixin, _AnimationGroupBase
Source code in prettyqt/core/animationgroup.py
| class AnimationGroupMixin(core.AbstractAnimationMixin, _AnimationGroupBase):
@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 __iter__(self) -> Iterator[core.QAbstractAnimation]:
return (self.animationAt(i) for i in range(self.animationCount()))
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) -> core.QObject:
"""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:
msg = "Could not find shared targetObject for all animations."
raise RuntimeError(msg)
return targets[0]
def add_property_animation(self, obj: types.MethodType) -> core.PropertyAnimation:
anim = core.PropertyAnimation()
anim.apply_to(obj)
self.addAnimation(anim)
return anim
|
targetObject() -> core.QObject
Return shared targetObject if existing.
Source code in prettyqt/core/animationgroup.py
| def targetObject(self) -> core.QObject:
"""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:
msg = "Could not find shared targetObject for all animations."
raise RuntimeError(msg)
return targets[0]
|
:fa-brands-github: Show source on GitHub