Adding Buttons Dynamically Kivy
<p>Kind of a 2 part-er. I feel a little silly because I know I'm missing something simple but I've been looking all day and can't find anything.</p>

<p>First:</p>

<p>I need to be able to add Buttons to a screen in screen manager. I can do it in a .kv file but can't get it to work in the .py file so I know I'm doing something wrong.</p>

<p>Second: I need to add it in the .py file (as far as I have read at least) because I will need to add a different amount of Buttons depending on how many items are in a list. So I have this test code which is really a fragment of my main code.</p>

<p>.py:</p>

<pre><code>from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.screenmanager import ScreenManager, Screen, FadeTransition

class Test(ScreenManager):
    pass

class StartMenu(Screen):
    pass

class LoadMenu(Screen):
    lay = FloatLayout()
    lay.add_widget(Button(text = 'Hi'))


class TestApp(App):
    def build(self):
        return Test()

if __name__=='__main__':
    TestApp().run()
</code></pre>

<p>and the .kv file:</p>

<pre><code>&lt;Test&gt;:    

    StartMenu:
        name: 'start_menu'

        FloatLayout:

            Button:

                size_hint: (.5, .10)
                pos_hint: {'center_x': .5, 'center_y' : .90}
                text: 'Play'
                color: [1, 0, 0, 1]

                font_size: self.height * 5/6
                border: [25, 25, 25, 25]
                on_press: root.current = 'load_menu'

    LoadMenu:
        name: 'load_menu'
</code></pre>

<p>so that just gives me a screen with a button and when I click that it sends me to a black screen. As I said I can get the load menu to display Buttons but that's only using the .kv file.
As for dynamically adding Buttons would a <code>for</code> loop work?</p>

<pre><code>L=['save 1', 'save 2', 'save 3']
for x in L:
    add_widget(Button(title = L[x]))
</code></pre>