当我尝试使用具有可变数量值的自己的列的每周进行一周视图时,不知何故具有最长值的行是唯一出现的行。我做错了什么?
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.gridlayout import GridLayout
from kivy.uix.button import Button
class TestApp(App):
def build(self):
print("run main")
weeklyView = GridLayout(cols=7)
weeklyTasks= [[],[1,2,3,4,5],[1,2,3,4,5,6,7,8,9,10,11,12,13],[],[1,2,3,4,5],[1,2,3],[]]
for dayOfWeek in range(0,7):
print(dayOfWeek)
filteredTasks= weeklyTasks[dayOfWeek]
dayLayout = GridLayout(cols = 1,row_force_default=True, row_default_height=100, size_hint_y=None);
dayLayout.bind(minimum_height=dayLayout.setter('height'))
header = Button(text='day')
print('add header')
dayLayout.add_widget(header)
for task in filteredTasks:
label = Button(text= str(task))
print(task)
label.text_size = label.size
dayLayout.add_widget(label)
weeklyView.add_widget(dayLayout)
mainLayout = BoxLayout()
mainLayout.add_widget(weeklyView)
return mainLayout
if __name__ == '__main__':
TestApp().run()