title: Change screen from python code Kivy
body: <p>So I have problem with changing my screen after my game ends.
  I have tried do it like this:</p>
  
  <pre><code>Manager.current = 'endmenu'
  </code></pre>
  
  <p>but it doesn't work. This is fragment of my code form kv and py files</p>
  
  <p>main.py, function where I use switch()</p>
  
  <pre><code>def bounce_ball(self, ball, score):
      """Check for collision between a ball and a circle"""
      dx = ball.center_x - self.center_x
      dy = ball.center_y - self.center_y
      #print("Ball: ",ball.center)
      #print("Center: ",self.center)
      distance = Vector(ball.center).distance(self.center) - 50
      if distance &gt;= 100 + 30 and distance &lt;= 100 + 30 + 4:# circle radius + ball size
          vx, vy = ball.velocity
          centertoballangle = Vector(0,1).angle((dx,dy))
          if centertoballangle &lt;= 0: #angle 0-360 not 0-180 to  -180-0
              centertoballangle += 360
          ball.angle = Vector(vx,vy).angle((dx,dy))
          if self.checkcolor(ball, centertoballangle, self.angle%360):
              bounced = Vector(vx,vy)
              if ball.angle &gt; 90:
                  ball.angle-=90
              elif ball.angle &lt; -90:
                  ball.angle+=90
              ball.angle = 180-2*ball.angle # set new angle off ball after bounce
              ball.touchspeed*=2 # make changing angle a bit more aggresive
              if ball.angle + ball.touchspeed &lt; 350 or ball.angle + ball.touchspeed &gt; 40:
                  ball.angle += ball.touchspeed # ball.touchspeed - change the angle!
              bounced = bounced.rotate(ball.angle) # finally, rotate the ball
              if score&lt;12:
                  vel = bounced * 1.1 # make ball move faster
              else:
                  vel = bounced
              ball.velocity = vel.x , vel.y
              ball.touchspeed=0
              return True # add +1 to score
          else:
              Manager.switch()
              return False
  </code></pre>
  
  <p>the edited screen manager class:</p>
  
  <pre><code>class Manager(ScreenManager):
      def __init__(self, *args, **kwargs):
          super(Manager, self).__init__(*args, **kwargs)
          self.current = 'menu'
      def switch(self, where):
          self.current = str(where)
  sm = Manager(transition=WipeTransition())
  
  class ColorPongApp(App):
      def build(self):
          return sm
  </code></pre>
  
  <p>and my kv file:</p>
  
  <pre><code>&lt;Manager&gt;
      Screen:
          name: 'menu'
          BoxLayout:
              Button:
                  text: 'Play Color Pong'
                  halign: 'center'
                  valign: 'middle'
                  font_size: 50
                  text_size: self.size
                  on_release: root.current = 'game';game.serve_ball()
              Button:
                  text: 'Quit'
                  halign: 'center'
                  valign: 'middle'
                  font_size: 50
                  text_size: self.size
                  on_release: game.quit()
  
      Screen:
          name: 'game'
          ColorPongGame:
              id: game
  
      Screen:
          name: 'endmenu'
          id: endmenu
          BoxLayout:
              Button:
                  text: 'Replay'
                  halign: 'center'
                  valign: 'middle'
                  font_size: 50
                  text_size: self.size
                  on_release: root.current = 'game';game.serve_ball()
              Button:
                  text: 'Quit'
                  halign: 'center'
                  valign: 'middle'
                  font_size: 50
                  text_size: self.size
                  on_release: game.quit()
  </code></pre>
  
  <p>all I want to do is change the screen and I think it can't be done because name 'endmenu' isn't known in python file, even with that knowledge I don't know how to fix this.</p>