return animation def __repr__(self): result = super().__repr__() if hasattr(self, "_card"): result += str(self._card) return result if __name__ == "__main__": def toggle_visible(clicked_card_widget: CardWidget): animation = clicked_card_widget.get_flip_animation(0.5, True) animation.start(clicked_card_widget) float_layout = FloatLayout() float_layout.size = 1000, 1000 deck = Card.get_all_cards() random.shuffle(deck) for _card in deck: card_widget = CardWidget(_card) card_widget.size = 240, 370 card_widget.grayed_out = random.random() > 0.5 card_widget.pos = random.randint(100, 900), random.randint(100, 900) card_widget.rotation = random.randint(0, 180) card_widget.bind(on_double_tap=toggle_visible) float_layout.add_widget(card_widget) runTouchApp(float_layout)
anim.stop(card_widget) self._animations = {} self._on_complete() def _on_complete(self) -> None: assert len(self._animations) == 0, self._animations self._state = _State.IDLE if self._on_complete_callback is not None: self._on_complete_callback() if __name__ == "__main__": EventLoop.ensure_window() EventLoop.window.size = 400, 400 _float_layout = FloatLayout() _float_layout.size = 400, 400 _float_layout.size_hint = 1, 1 _animation_controller = AnimationController() _animation = Animation(rotation=-45) + \ Animation(center_x=_float_layout.width / 4, center_y=_float_layout.height / 4) + \ Animation(rotation=270) + \ Animation(center_x=_float_layout.width / 4 * 3, center_y=_float_layout.height / 4) + \ Animation(rotation=270 + 90) + \ Animation(center_x=_float_layout.width / 4 * 3, center_y=_float_layout.height / 4 * 3) + \ Animation(rotation=90) + \ Animation(center_x=_float_layout.width / 4, center_y=_float_layout.height / 4 * 3) + \