Skip to content

Commit

Permalink
use correct transition in screen_manager.switch_to if user passes opt…
Browse files Browse the repository at this point in the history
…ion like it's described in the docs
  • Loading branch information
hansent committed Dec 13, 2013
1 parent 9a941dc commit fdd0ff3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions kivy/uix/screenmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,7 @@ def switch_to(self, screen, **options):
raise ScreenManagerException(
'ScreenManager accepts only Screen widget.')


# stop any transition that might be happening already
self.transition.stop()

Expand All @@ -933,6 +934,12 @@ def switch_to(self, screen, **options):
if self.has_screen(screen.name):
screen.name = self._generate_screen_name()

# change the transition if given explicitly
old_transition = self.transition
specified_transition = options.pop("transition", None)
if specified_transition:
self.transition = specified_transition

# change the transition options
for key, value in iteritems(options):
setattr(self.transition, key, value)
Expand All @@ -947,6 +954,7 @@ def switch_to(self, screen, **options):
def remove_old_screen(transition):
if old_current in self.children:
self.remove_widget(old_current)
self.transition = old_transition
transition.unbind(on_complete=remove_old_screen)
self.transition.bind(on_complete=remove_old_screen)

Expand Down

0 comments on commit fdd0ff3

Please sign in to comment.