Python kivy.animation.Animation() Examples
The following are 30
code examples of kivy.animation.Animation().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
kivy.animation
, or try the search function
.
Example #1
Source File: flatui.py From kivy-material-ui with MIT License | 6 votes |
def add_to_bottom_right( self, parent ) : nx = parent.width-self.diameter*1.2 ny = self.diameter*0.3 parent.bind( size=self._repose ) parent.add_widget( self ) duracy = self.animation_duracy if self.entrance != '' else 0 if duracy > 0 : if self.entrance == 'down' : self.pos = [ nx, -self.height ] if self.entrance == 'up' : self.pos = [ nx, self.pos[1]+self.height ] if self.entrance == 'left' : self.pos = [ -self.width, ny ] if self.entrance == 'right' : self.pos = [ +self.width, ny ] animation = Animation( x=nx, y=ny, duration=duracy ) animation.start( self ) else : self.pos = nx, ny self.parent = parent
Example #2
Source File: __init__.py From RaceCapture_App with GNU General Public License v3.0 | 6 votes |
def stop_spinning(self, *args): '''Stop spinning the progress spinner. Ignores all positional args for easy binding. If you intend to keep the spinner around, you should stop it when not using it and restart it when needed again. ''' if self._spinning: if self._next: if isinstance(self._next, Animation): self._next.cancel(self) else: self._next.cancel() Clock.unschedule(self._update) Clock.unschedule(self._rotate) self._angle_start = self._angle_end = 0 self._spinning = False
Example #3
Source File: dialog.py From KivyMD with MIT License | 6 votes |
def open(self, *largs): '''Show the view window from the :attr:`attach_to` widget. If set, it will attach to the nearest window. If the widget is not attached to any window, the view will attach to the global :class:`~kivy.core.window.Window`. ''' if self._window is not None: Logger.warning('ModalView: you can only open once.') return self # search window self._window = self._search_window() if not self._window: Logger.warning('ModalView: cannot open view, no window found.') return self self._window.add_widget(self) self._window.bind(on_resize=self._align_center, on_keyboard=self._handle_keyboard) self.center = self._window.center self.bind(size=self._update_center) a = Animation(_anim_alpha=1., d=self._anim_duration) a.bind(on_complete=lambda *x: self.dispatch('on_open')) a.start(self) return self
Example #4
Source File: scroll.py From kivy-material-ui with MIT License | 6 votes |
def start( self ) : self.pos = ( self.root_layout.width/2 - self.width/2, self.root_layout.height+self.height-dp(56) ) animation = Animation( y=self.root_layout.height-2*self.height, duration=self.duracy ) animation.start( self ) self.angle = 0 self._hex = 0 self._color = 0, 0, 0, 1 self.root_layout.add_widget( self ) Clock.schedule_interval( self.update_animation, 0.04 )
Example #5
Source File: inspector.py From Tickeys-linux with MIT License | 6 votes |
def on_activated(self, instance, activated): if not activated: self.grect.size = 0, 0 if self.at_bottom: anim = Animation(top=0, t='out_quad', d=.3) else: anim = Animation(y=self.height, t='out_quad', d=.3) anim.bind(on_complete=self.animation_close) anim.start(self.layout) self.widget = None self.widget_info = False else: self.win.add_widget(self) Logger.info('Inspector: inspector activated') if self.at_bottom: Animation(top=60, t='out_quad', d=.3).start(self.layout) else: Animation(y=self.height - 60, t='out_quad', d=.3).start( self.layout)
Example #6
Source File: screenmanager.py From Tickeys-linux with MIT License | 6 votes |
def start(self, manager): '''(internal) Starts the transition. This is automatically called by the :class:`ScreenManager`. ''' if self.is_active: raise ScreenManagerException('start() is called twice!') self.manager = manager self._anim = Animation(d=self.duration, s=0) self._anim.bind(on_progress=self._on_progress, on_complete=self._on_complete) self.add_screen(self.screen_in) self.screen_in.transition_progress = 0. self.screen_in.transition_state = 'in' self.screen_out.transition_progress = 0. self.screen_out.transition_state = 'out' self.screen_in.dispatch('on_pre_enter') self.screen_out.dispatch('on_pre_leave') self.is_active = True self._anim.start(self) self.dispatch('on_progress', 0)
Example #7
Source File: dialog.py From Blogs-Posts-Tutorials with MIT License | 6 votes |
def open(self, *largs): '''Show the view window from the :attr:`attach_to` widget. If set, it will attach to the nearest window. If the widget is not attached to any window, the view will attach to the global :class:`~kivy.core.window.Window`. ''' if self._window is not None: Logger.warning('ModalView: you can only open once.') return self # search window self._window = self._search_window() if not self._window: Logger.warning('ModalView: cannot open view, no window found.') return self self._window.add_widget(self) self._window.bind(on_resize=self._align_center, on_keyboard=self._handle_keyboard) self.center = self._window.center self.bind(size=self._align_center) a = Animation(_anim_alpha=1., d=self._anim_duration) a.bind(on_complete=lambda *x: self.dispatch('on_open')) a.start(self) return self
Example #8
Source File: screenmanager.py From Tickeys-linux with MIT License | 6 votes |
def start(self, manager): '''(internal) Starts the transition. This is automatically called by the :class:`ScreenManager`. ''' if self.is_active: raise ScreenManagerException('start() is called twice!') self.manager = manager self._anim = Animation(d=self.duration, s=0) self._anim.bind(on_progress=self._on_progress, on_complete=self._on_complete) self.add_screen(self.screen_in) self.screen_in.transition_progress = 0. self.screen_in.transition_state = 'in' self.screen_out.transition_progress = 0. self.screen_out.transition_state = 'out' self.screen_in.dispatch('on_pre_enter') self.screen_out.dispatch('on_pre_leave') self.is_active = True self._anim.start(self) self.dispatch('on_progress', 0)
Example #9
Source File: modalview.py From Tickeys-linux with MIT License | 6 votes |
def open(self, *largs): '''Show the view window from the :attr:`attach_to` widget. If set, it will attach to the nearest window. If the widget is not attached to any window, the view will attach to the global :class:`~kivy.core.window.Window`. ''' if self._window is not None: Logger.warning('ModalView: you can only open once.') return self # search window self._window = self._search_window() if not self._window: Logger.warning('ModalView: cannot open view, no window found.') return self self._window.add_widget(self) self._window.bind( on_resize=self._align_center, on_keyboard=self._handle_keyboard) self.center = self._window.center self.bind(size=self._update_center) a = Animation(_anim_alpha=1., d=self._anim_duration) a.bind(on_complete=lambda *x: self.dispatch('on_open')) a.start(self) return self
Example #10
Source File: inspector.py From Tickeys-linux with MIT License | 6 votes |
def on_activated(self, instance, activated): if not activated: self.grect.size = 0, 0 if self.at_bottom: anim = Animation(top=0, t='out_quad', d=.3) else: anim = Animation(y=self.height, t='out_quad', d=.3) anim.bind(on_complete=self.animation_close) anim.start(self.layout) self.widget = None self.widget_info = False else: self.win.add_widget(self) Logger.info('Inspector: inspector activated') if self.at_bottom: Animation(top=60, t='out_quad', d=.3).start(self.layout) else: Animation(y=self.height - 60, t='out_quad', d=.3).start( self.layout)
Example #11
Source File: control.py From kivy-material-ui with MIT License | 5 votes |
def _run_pop_animation( self ) : try : self._temp_view.disabled = self.disable_widget x = self._temp_view.width * ( -1 if self.push_mode == 'left' else 1 ) self._animation = Animation( x=x, duration=self.animation_duracy ) self._animation.bind( on_complete=self._pop_temp_view ) self._animation.start( self._temp_view ) except : pass #Exception as e : print(e)
Example #12
Source File: navigationdrawer.py From Blogs-Posts-Tutorials with MIT License | 5 votes |
def _get_main_animation(self, duration, t, x, is_closing): a = super(NavigationDrawer, self)._get_main_animation(duration, t, x, is_closing) a &= Animation(elevation=0 if is_closing else 5, t=t, duration=duration) return a
Example #13
Source File: __init__.py From RaceCapture_App with GNU General Public License v3.0 | 5 votes |
def _rotate(self, *args): if not self._spinning: return rotate_speed = 0.6 / self.speed wait_speed = 0.3 / self.speed if self._state == 'wait1': self._state = 'rotate1' self._next = Animation(_angle_end=self._angle_start + 360. - self.stroke_length, d=rotate_speed, t='in_quad') self._next.bind(on_complete=self._rotate) self._next.start(self) elif self._state == 'rotate1': self._state = 'wait2' self._next = Clock.schedule_once(self._rotate, wait_speed) elif self._state == 'wait2': self._state = 'rotate2' self._next = Animation(_angle_start=self._angle_end - self.stroke_length, d=rotate_speed, t='in_quad') self._next.bind(on_complete=self._rotate) self._next.start(self) elif self._state == 'rotate2': self._state = 'wait1' self._next = Clock.schedule_once(self._rotate, wait_speed) while self._angle_end > 720.: self._angle_start -= 360. self._angle_end -= 360.
Example #14
Source File: widget.py From segreto-3 with MIT License | 5 votes |
def show(self, desc): self.text = desc anim = Animation(y = metrics.dp(50), t = 'in_out_expo') anim.start(self) Clock.schedule_once(self.exit, 5)
Example #15
Source File: __init__.py From Blogs-Posts-Tutorials with MIT License | 5 votes |
def _get_main_animation(self, duration, t, x, is_closing): a = super(NavigationDrawer, self)._get_main_animation(duration, t, x, is_closing) a &= Animation(elevation=0 if is_closing else 5, t=t, duration=duration) return a
Example #16
Source File: snackbar.py From Blogs-Posts-Tutorials with MIT License | 5 votes |
def die(self): anim = Animation(top=0, duration=.3, t='out_quad') anim.bind(on_complete=lambda *args: _play_next(self)) anim.bind(on_complete=lambda *args: Window.remove_widget(self)) anim.start(self)
Example #17
Source File: snackbar.py From Blogs-Posts-Tutorials with MIT License | 5 votes |
def begin(self): if self.button_text == '': self.remove_widget(self.ids['_button']) else: self.ids['_spacer'].width = dp(16) if \ DEVICE_TYPE == "mobile" else dp(40) self.padding_right = dp(16) Window.add_widget(self) anim = Animation(y=0, duration=.3, t='out_quad') anim.start(self) Clock.schedule_once(lambda dt: self.die(), self.duration)
Example #18
Source File: flatui.py From kivy-material-ui with MIT License | 5 votes |
def remove_from_parent( self ) : duracy = self.animation_duracy if self.entrance != '' else 0 nx, ny = self.pos if self.entrance == 'down' : ny = 0 if self.entrance == 'up' : ny = self.parent.height+self.height if self.entrance == 'left' : nx = -self.width if self.entrance == 'right' : nx = self.parent.width animation = Animation( x=nx, y=ny, duration=duracy ) animation.bind( on_complete=self._remove_from_parent ) animation.start( self )
Example #19
Source File: dialog.py From Blogs-Posts-Tutorials with MIT License | 5 votes |
def dismiss(self, *largs, **kwargs): '''Close the view if it is open. If you really want to close the view, whatever the on_dismiss event returns, you can use the *force* argument: :: view = ModalView(...) view.dismiss(force=True) When the view is dismissed, it will be faded out before being removed from the parent. If you don't want animation, use:: view.dismiss(animation=False) ''' if self._window is None: return self if self.dispatch('on_dismiss') is True: if kwargs.get('force', False) is not True: return self if kwargs.get('animation', True): Animation(_anim_alpha=0., d=self._anim_duration).start(self) else: self._anim_alpha = 0 self._real_remove_widget() return self
Example #20
Source File: HexTile.py From hexTap with BSD 3-Clause "New" or "Revised" License | 5 votes |
def move_up(self, use_star): if self.level == MAX_LEVEL: return self.level += 1 anim = Animation(y=self.pos[1] + 34, t='in_out_elastic', duration=.7) anim.start(self) if self.player: actor_anim = Animation(y=self.player.pos[1] + 34, t='in_out_elastic', duration=.7) actor_anim.start(self.player) if self.mod_layer: actor_anim = Animation(y=self.mod_layer.pos[1] + 34, t='in_out_elastic', duration=.7) actor_anim.start(self.mod_layer) if self.star: actor_anim = Animation(y=self.star.pos[1] + 34, t='in_out_elastic', duration=.7) actor_anim.start(self.star) if self.key: actor_anim = Animation(y=self.key.pos[1] + 34, t='in_out_elastic', duration=.7) actor_anim.start(self.key) if self.exit: actor_anim = Animation(y=self.exit.pos[1] + 34, t='in_out_elastic', duration=.7) actor_anim.start(self.exit) if self.portal: portal_anim = Animation(y=self.portal.pos[1] + 34, t='in_out_elastic', duration=.7) portal_anim.start(self.portal) if use_star: self.game_map.tile_with_player.player.use_star()
Example #21
Source File: HexScatter.py From hexTap with BSD 3-Clause "New" or "Revised" License | 5 votes |
def move_hex_down(self, use_star=True): if self.tile_with_player.player.stars > 0: self.selected_hex.move_down(use_star) for enemy in self.enemy_list: if self.selected_hex.actor and enemy.col == self.selected_hex.col and enemy.row == self.selected_hex.row: actor_anim = Animation(y=enemy.pos[1] - 34, t='in_out_elastic', duration=.7) actor_anim.start(enemy) break if use_star: self.parent.counter.update_counter(-1)
Example #22
Source File: HexScatter.py From hexTap with BSD 3-Clause "New" or "Revised" License | 5 votes |
def move_hex_up(self, use_star=True): if self.tile_with_player.player.stars > 0: self.selected_hex.move_up(use_star) for enemy in self.enemy_list: if self.selected_hex.actor and enemy.col == self.selected_hex.col and enemy.row == self.selected_hex.row: actor_anim = Animation(y=enemy.pos[1] + 34, t='in_out_elastic', duration=.7) actor_anim.start(enemy) break if use_star: self.parent.counter.update_counter(-1)
Example #23
Source File: HexScatter.py From hexTap with BSD 3-Clause "New" or "Revised" License | 5 votes |
def player_has_all_exits(self): if self.tile_with_player.exit: self.score += 10 * self.difficulty self.parent.counter.update_counter(0, 10 * self.difficulty) for key in self.player_has_keys: if self.tile_with_player.exit_type == key_exit[key]: self.player_has_exits += 1 exit_anim = Animation(x=self.tile_with_player.exit.x, y=self.tile_with_player.exit.y + 80, duration=0.15) exit_anim.start(self.tile_with_player.exit) exit_anim.bind(on_complete=self.tile_with_player.remove_exit) if self.tile_with_player.exit_type == 'lockYellow': self.parent.star_counter.ids.keyYellow.source = lock_sources[self.tile_with_player.exit_type] self.parent.star_counter.ids.keyYellow.reload() if self.tile_with_player.exit_type == 'lockGreen': self.parent.star_counter.ids.keyGreen.source = lock_sources[self.tile_with_player.exit_type] self.parent.star_counter.ids.keyGreen.reload() if self.tile_with_player.exit_type == 'lockBlue': self.parent.star_counter.ids.keyBlue.source = lock_sources[self.tile_with_player.exit_type] self.parent.star_counter.ids.keyBlue.reload() elif self.tile_with_player.exit_type == 'lockOrange': self.parent.star_counter.ids.keyOrange.source = lock_sources[self.tile_with_player.exit_type] self.parent.star_counter.ids.keyOrange.reload() if len(self.player_has_keys) == self.difficulty and self.player_has_exits == self.difficulty: self.player_won = True self.complete_level() return True
Example #24
Source File: HexScatter.py From hexTap with BSD 3-Clause "New" or "Revised" License | 5 votes |
def handle_key(self): if self.tile_with_player.key: self.score += 5 * self.difficulty self.parent.counter.update_counter(0, 5 * self.difficulty) self.player_has_keys.append(self.tile_with_player.key_type) key_anim = Animation(x=self.tile_with_player.key.x, y=self.tile_with_player.key.y + 80, duration=0.15) key_anim.start(self.tile_with_player.key) key_id = self.tile_with_player.key_type if key_id == 'keyYellow': self.parent.star_counter.ids.keyYellow.source = key_sources[self.tile_with_player.key_type] self.parent.star_counter.ids.keyYellow.reload() elif key_id == 'keyGreen': self.parent.star_counter.ids.keyGreen.source = key_sources[self.tile_with_player.key_type] self.parent.star_counter.ids.keyGreen.reload() elif key_id == 'keyOrange': self.parent.star_counter.ids.keyOrange.source = key_sources[self.tile_with_player.key_type] self.parent.star_counter.ids.keyOrange.reload() elif key_id == 'keyBlue': self.parent.star_counter.ids.keyBlue.source = key_sources[self.tile_with_player.key_type] self.parent.star_counter.ids.keyBlue.reload() key_anim.bind(on_complete=self.tile_with_player.remove_key) if self.soundsOption: pick_key_sound = SoundLoader.load('assets/audio/pick_key.ogg') pick_key_sound.play()
Example #25
Source File: HexScatter.py From hexTap with BSD 3-Clause "New" or "Revised" License | 5 votes |
def handle_star(self): if self.tile_with_player.star: self.score += 1 * self.difficulty self.parent.counter.update_counter(1, 1 * self.difficulty) if self.soundsOption: pick_star_sound = SoundLoader.load('assets/audio/pick_star.ogg') pick_star_sound.play() star_anim = Animation(x=self.tile_with_player.star.x, y=self.tile_with_player.star.y + 80, duration=0.15) star_anim.start(self.tile_with_player.star) star_anim.bind(on_complete=self.tile_with_player.remove_star) self.tile_with_player.player.add_star()
Example #26
Source File: HexScatter.py From hexTap with BSD 3-Clause "New" or "Revised" License | 5 votes |
def is_player_dead(self): if self.player_death: self.tile_with_player.player.player_dead() death_anim = Animation(x=self.tile_with_player.player.y + 500, duration=0.1) death_anim.start(self.tile_with_player.player) death_anim.bind(on_complete=self.player_remove_on_death) self.player_death = True self.complete_level() return True
Example #27
Source File: HexScatter.py From hexTap with BSD 3-Clause "New" or "Revised" License | 5 votes |
def move_to_hex_prep(self, dt): self.remove_skip_turn() self.player_death = False self.enemy_death = False self.death_anim = Animation(y=self.to_hex.pos[1] + 500, duration=0.3) from_level, to_level = level_diff(self.from_hex, self.to_hex) if abs(to_level - from_level) > 1 or self.check_proximity(self.to_hex): self.end_without_movement(no_move=True, show_too_far=True) return elif to_level - from_level == 1: if self.to_hex.actor: self.player_death = True self.move_anim = Animation(x=self.to_hex.pos[0] + 10, duration=0.1) self.move_anim &= Animation(y=self.to_hex.pos[1] + 279, t='out_back', duration=0.3) jump = True elif to_level - from_level == -1: if self.to_hex.actor: self.enemy_death = True self.move_anim = Animation(x=self.to_hex.pos[0] + 10, duration=0.1) self.move_anim &= Animation(y=self.to_hex.pos[1] + 279, t='out_back', duration=0.3) jump = True else: if self.to_hex.actor: self.player_death = True jump = False self.move_anim = Animation(x=self.to_hex.pos[0] + 10, y=self.to_hex.pos[1] + 279, duration=0.5) self.is_moving = True if jump: self.player_is_jumping = True else: self.player_is_jumping = False if not self.is_move_mode: return self.player = self.from_hex.player self.from_hex.remove_player() self.add_widget(self.player) self.complete_player_movement(jump)
Example #28
Source File: accordion.py From Tickeys-linux with MIT License | 5 votes |
def on_collapse(self, instance, value): accordion = self.accordion if accordion is None: return if not value: self.accordion.select(self) collapse_alpha = float(value) if self._anim_collapse: self._anim_collapse.stop() self._anim_collapse = None if self.collapse_alpha != collapse_alpha: self._anim_collapse = Animation( collapse_alpha=collapse_alpha, t=accordion.anim_func, d=accordion.anim_duration).start(self)
Example #29
Source File: modalview.py From Tickeys-linux with MIT License | 5 votes |
def dismiss(self, *largs, **kwargs): '''Close the view if it is open. If you really want to close the view, whatever the on_dismiss event returns, you can use the *force* argument: :: view = ModalView(...) view.dismiss(force=True) When the view is dismissed, it will be faded out before being removed from the parent. If you don't want animation, use:: view.dismiss(animation=False) ''' if self._window is None: return self if self.dispatch('on_dismiss') is True: if kwargs.get('force', False) is not True: return self if kwargs.get('animation', True): Animation(_anim_alpha=0., d=self._anim_duration).start(self) else: self._anim_alpha = 0 self._real_remove_widget() return self
Example #30
Source File: inspector.py From Tickeys-linux with MIT License | 5 votes |
def show_widget_info(self): self.content.clear_widgets() widget = self.widget treeview = self.treeview for node in list(treeview.iterate_all_nodes())[:]: node.widget_ref = None treeview.remove_node(node) if not widget: if self.at_bottom: Animation(top=60, t='out_quad', d=.3).start(self.layout) else: Animation(y=self.height - 60, t='out_quad', d=.3).start( self.layout) self.widget_info = False return self.widget_info = True if self.at_bottom: Animation(top=250, t='out_quad', d=.3).start(self.layout) else: Animation(top=self.height, t='out_quad', d=.3).start(self.layout) for node in list(treeview.iterate_all_nodes())[:]: treeview.remove_node(node) keys = list(widget.properties().keys()) keys.sort() node = None wk_widget = weakref.ref(widget) for key in keys: text = '%s' % key node = TreeViewProperty(text=text, key=key, widget_ref=wk_widget) node.bind(is_selected=self.show_property) try: widget.bind(**{key: partial( self.update_node_content, weakref.ref(node))}) except: pass treeview.add_node(node)