Object order in StackLayout (Kivy)
<p>I have a </p>

<pre><code>layout = StackLayout()
</code></pre>

<p>now I put buttons like this</p>

<pre><code>for x in range(9): # range() explanation: http://pythoncentral.io/pythons-range-function-explained/
            bt = Button(text=' ', font_size=200, width=200, height=200, size_hint=(None, None), id=str(x+1))
            bt.bind(on_release=self.btn_pressed)
            layout.add_widget(bt)
</code></pre>

<p>the problem is that when I go through layout.children array and show the ids they come in order <code>9,8,7,6,5,4,3,2,1</code> which is reversed and not what I want. How do I get them in proper order? (Reversing the array is not a solution)</p>

<p>Another example</p>

<p>I have:</p>

<pre><code>        self.layout = StackLayout()
        bt = Button(text='1', font_size=200, width=200, height=200, size_hint=(None, None), id="1")
        bt1 = Button(text='2', font_size=200, width=200, height=200, size_hint=(None, None), id="2")
        bt2 = Button(text='3', font_size=200, width=200, height=200, size_hint=(None, None), id="3")
        bt3 = Button(text='4', font_size=200, width=200, height=200, size_hint=(None, None), id="4")
        bt4 = Button(text='5', font_size=200, width=200, height=200, size_hint=(None, None), id="5")
        bt5 = Button(text='6', font_size=200, width=200, height=200, size_hint=(None, None), id="6")
        self.layout.add_widget(bt, 1)
        self.layout.add_widget(bt1, 2)
        self.layout.add_widget(bt2, 3)
        self.layout.add_widget(bt3, 4)
        self.layout.add_widget(bt4, 5)
        self.layout.add_widget(bt5, 6)
</code></pre>

<p>And this shows me this: <img src="http://i.stack.imgur.com/1hgV2.png" alt="enter image description here"></p>

<p>a possible trick would be:</p>

<pre><code>y = 10

for x in range(y):
        bt = Button(text=' ', font_size=200, width=200, height=200, size_hint=(None, None), id=str(y-x))
        bt.bind(on_release=self.btn_pressed)
        layout.add_widget(bt)
</code></pre>

python layout order kivy