def func(): S = Sleep yield S(0) start_time = time() yield S(.5) | S(1) self.assertAlmostEqual(time() - start_time, .5, delta=self.DELTA) yield S(2) | S(1) self.assertAlmostEqual(time() - start_time, 1.5, delta=self.DELTA) stopTouchApp()
def handle_click(self, btn): self.__game.play_at(*btn.grid_pos) # args unpacking self.update_all_buttons() if self.__game.finished(): popup = Popup(title='Game finished', content=Button(text=self.__game.message())) popup.content.bind(on_release=popup.dismiss) popup.open() stopTouchApp()
def func(): image = root.ids.image label = root.ids.label anim1 = Animation(opacity=0) anim2 = Animation(opacity=0, d=.5) anim1.start(image) anim2.start(label) yield Event(anim1, 'on_complete') & Event(anim2, 'on_complete') self.assertEqual(image.opacity, 0) self.assertEqual(label.opacity, 0) stopTouchApp()
def func(): S = Sleep yield S(0) start_time = time() yield Wait(events=( S(.5), S(1), )) self.assertAlmostEqual(time() - start_time, 1.0, delta=self.DELTA) yield Wait(events=(S(.5), S(1), S(1.5)), n=2) self.assertAlmostEqual(time() - start_time, 2.0, delta=self.DELTA) stopTouchApp()
def func(): image = root.ids.image label = root.ids.label anim1 = Animation(opacity=0) anim2 = Animation(opacity=0, d=.5) anim1.start(image) anim2.start(label) yield Wait( events=( Event(anim1, 'on_complete'), Event(anim2, 'on_complete'), ), n=1, ) self.assertAlmostEqual(image.opacity, 0.5, delta=.1) self.assertEqual(label.opacity, 0) stopTouchApp()
def func(): A = Animation E = Event S = Sleep image = root.ids.image label = root.ids.label a1 = A(opacity=0, d=2) a2 = A(opacity=0) yield S(0) a1.start(image) a2.start(label) yield E(a1, 'on_complete') | S(.5) | E(a2, 'on_complete') self.assertAlmostEqual(image.opacity, 0.75, delta=0.1) self.assertAlmostEqual(label.opacity, 0.5, delta=0.1) yield E(a1, 'on_complete') | E(a2, 'on_complete') self.assertAlmostEqual(image.opacity, 0.5, delta=0.1) self.assertEqual(label.opacity, 0) yield E(a1, 'on_complete') | E(a2, 'on_complete') self.assertEqual(label.opacity, 0) self.assertEqual(image.opacity, 0) stopTouchApp()
def change_turn(dt): """change_turn """ #server changes turn (via game-state) score_board.render_turn(2) print("assert", "change turn") assert not score_board.col1.children[1].active assert score_board.col2.children[1].active # server set score (via game-state) print("assert", "update score") score_board.render_game_state({ "scores": [2, 7], "in-device": False }) KivyClock.schedule_once(lambda dt: stopTouchApp(), 5)
def check_stop_app(): if stop_app: stopTouchApp() if finished_callback: finished_callback()
def func(): Clock.schedule_once(lambda __: setattr(root, 'font_size', 20), .5) yield Event(root, 'font_size') self.assertEqual(root.font_size, 20) stopTouchApp()
def func(): anim = Animation(opacity=0) anim.start(root) yield Event(anim, 'on_complete') self.assertEqual(root.opacity, 0) stopTouchApp()