title: Kivy Adding Widget to a screen
body: <p>This seems to be a silly question. But I have a widget that I want to add to a screen called GameScreen. </p>
  
  <p>This is my Python code: </p>
  
  <pre><code>class WelcomeScreen(Screen):
      pass
  
  class BasicScreen(Screen):
      pass
  
  class GameScreen(Screen):
      parent = Widget()
      game =  ShootingGame()
      parent.add_widget(game)
      Clock.schedule_interval(game.update, 1.0 / 60.0)
      # return parent
  
  sm = ScreenManager()
  sm.add_widget(WelcomeScreen(name='welcome'))
  sm.add_widget(BasicScreen(name='basic'))
  sm.add_widget(GameScreen(name='game'))
  
  class ShootingApp(App):
      def build(self):
          print(sm.current)
         return sm
  
  if __name__ == '__main__':  
      ShootingApp().run()
  </code></pre>
  
  <p>And this is my kivy code:</p>
  
  <pre><code>&lt;WelcomeScreen&gt;:
  Button:
      text: "Learn about haptic illusions"
      size_hint: None, None
      size: 500, 70
      pos: 100, 200
      font_size: 30
      on_release: app.root.current = "basic"
  
  Button:
      text: "Play our game"
      size_hint: None, None
      size: 500, 70
      pos: 100, 100
      font_size: 30
      on_release: app.root.current = "game"
  
  &lt;BasicScreen&gt;:
  name: "basic"
  
  &lt;GameScreen&gt;:
  name: "game"
  </code></pre>
  
  <p>The error I am getting is this. And I think this is because I already defined a parent for the widget game. However, I need that parent because the game widget uses width and height values of its parent (e.g., self.parent.width). Is there any workaround for this so that the game widget can be nested in a parent and add the parent to the screen? </p>
  
  <pre><code>kivy.uix.widget.WidgetException: Cannot add &lt;Screen name='game'&gt;, it already has a parent &lt;kivy.uix.widget.Widget object at 0x1093dc8d8&gt;
  </code></pre>
  
  <p>Thanks guys!!</p>