title: Kivy: changing screen from python code
body: <p>I'm putting together a Kivy app and am having some problems working out how to change screens at an arbitrarily chosen point within the python code.</p>
  
  <p>In the following example, I would like to know how to switch from <code>Screen2</code> back to <code>Screen1</code> by executing a function my <code>main.py</code> file.</p>
  
  <p>Here's my <code>main.py</code>:</p>
  
  <pre><code># -*- coding: utf-8 -*-
  
  from kivy.app import App
  from kivy.uix.screenmanager import ScreenManager, Screen, NoTransition
  from kivy.properties import ObjectProperty
  from functools import partial
  
  import random
  import time
  
  class ScreenOne(Screen):
      pass
  
  class ScreenTwo(Screen):
  
      def __init__(self,**kwargs):
          super(ScreenTwo, self).__init__(**kwargs)
          self.displayScreenThenLeave()
  
      def displayScreenThenLeave(self):
          # 'time.sleep(3)' is a stand-in for "execute some code here"
          time.sleep(3)
          self.changeScreen()
  
      # I want this function to send the user back to ScreenOne.
      def changeScreen(self):
          pass
  
  class Manager(ScreenManager):
  
      screen_one = ObjectProperty(None)
      screen_two = ObjectProperty(None)
  
  class ScreensApp(App):
  
      def build(self):
          m = Manager(transition=NoTransition())
          return m
  
  if __name__ == "__main__":
      ScreensApp().run()
  </code></pre>
  
  <p>And here's my <code>screens.kv</code>:</p>
  
  <pre><code>#:kivy 1.8.0
  
  &lt;ScreenOne&gt;:
  
      BoxLayout:
          orientation: "vertical"
          size: root.size
          spacing: 20
          padding: 20
  
          Label:
              text: "Main Menu"
          Button:
              text: "Button 1"
              on_release: root.manager.current = "screen2"
  
  &lt;ScreenTwo&gt;:        
  
      BoxLayout:
          orientation: "vertical"
          size: root.size
          spacing: 20
          padding: 20
  
          Label:
              id: label
              text: "Welcome to Screen 2, please wait three seconds"
  
  &lt;Manager&gt;:
      id: screen_manager
  
      screen_one: screen_one
      screen_two: screen_two
  
      ScreenOne:
          id: screen_one
          name: "screen1"
          manager: screen_manager
  
      ScreenTwo:
          id: screen_two
          name: "screen2"
          manager: screen_manager
  </code></pre>
  
  <p>As should be pretty evident, I'm a total beginner at Kivy, so I'd really appreciate it if you could show me exactly what I need to change, including the specific syntax that should be used.</p>
  
  <p>Thanks in advance for your time and wisdom.</p>