Reputation: 61
So I am new to kivy and I am trying to make list of buttons scrollable. The thing is that i couldn't get scrollview to work, then I stumbled upon Kivy ScrollView - Not Scrolling. When I added it to my code it still didn't work. Then I tried printing the minimum_height and it always printed 0 no matter how many buttons there were...
This is the code(it is really badly wrote but this is just for testing purposes, I will probably rewrite it when I manage the scrolling):
def on_pre_enter(self, *args):
mainLayout = RelativeLayout()
self.add_widget(mainLayout)
scroll = ScrollView(do_scroll_x = False)
infoLayout = GridLayout(cols = 1, size_hint = (0.5, None), pos_hint={"top":0.8,"center_x":0.5})
mainLayout.add_widget(scroll)
scroll.add_widget(infoLayout)
InfoWidgetButton = Button(text='Hello world', font_size=14, size_hint=(0.5, None), height = 30, pos_hint={"top":0.8,"center_x":0.5}, on_release= lambda x:self.buttonPress(infoLayout))
infoLayout.add_widget(InfoWidgetButton)
InfoWidgetButton = Button(text='Hello world', font_size=14, size_hint=(0.5, None), height=30,
pos_hint={"top": 0.8, "center_x": 0.5},
on_release=lambda x: self.buttonPress(infoLayout))
infoLayout.add_widget(InfoWidgetButton)
InfoWidgetButton = Button(text='Hello world', font_size=14, size_hint=(0.5, None), height=30,
pos_hint={"top": 0.8, "center_x": 0.5},
on_release=lambda x: self.buttonPress(infoLayout))
infoLayout.add_widget(InfoWidgetButton)
InfoWidgetButton = Button(text='Hello world', font_size=14, size_hint=(0.5, None), height=30,
pos_hint={"top": 0.8, "center_x": 0.5},
on_release=lambda x: self.buttonPress(infoLayout))
infoLayout.add_widget(InfoWidgetButton)
InfoWidgetButton = Button(text='Hello world', font_size=14, size_hint=(0.5, None), height=30,
pos_hint={"top": 0.8, "center_x": 0.5},
on_release=lambda x: self.buttonPress(infoLayout))
infoLayout.add_widget(InfoWidgetButton)
InfoWidgetButton = Button(text='Hello world', font_size=14, size_hint=(0.5, None), height=30,
pos_hint={"top": 0.8, "center_x": 0.5},
on_release=lambda x: self.buttonPress(infoLayout))
infoLayout.add_widget(InfoWidgetButton)
InfoWidgetButton = Button(text='Hello world', font_size=14, size_hint=(0.5, None), height=30,
pos_hint={"top": 0.8, "center_x": 0.5},
on_release=lambda x: self.buttonPress(infoLayout))
infoLayout.add_widget(InfoWidgetButton)
infoLayout.height = infoLayout.minimum_height
print(infoLayout.minimum_height)
Upvotes: 1
Views: 241
Reputation: 61
A guy answered my question on reddit: https://www.reddit.com/r/kivy/comments/irats0/kivy_grid_layouts_minimum_height_is_0/
Upvotes: 1