我有一個對象爲了
layout = StackLayout()
現在我把按鈕這樣
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)
的問題是,當我經過layout.children陣列,並顯示他們的IDS順序9,8,7,6,5,4,3,2,1
這是倒過來,而不是我想要的。我如何讓他們按正確的順序? (倒車陣列不是溶液)
又如
我有:
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)
這說明我:
你爲什麼在乎它被顛倒? – Juggernaut
它總是有意義的,你寫和從0讀到X,爲什麼相反,哈哈? – LimoTuz
我真的不知道它爲什麼對你很重要 – Juggernaut