'How do I use buttons inside of a GridLayout in a ScrollView in Kivy?
While designing a GUI using Kivy in Python, I encountered an issue when I place some buttons inside of a GridLayout, and the GridLayout inside of a ScrollView. The issue is that the buttons just don't take inputs anymore. Not sure what to do.
here is an example of what I'm trying to do, however, the button for some reason won't press.
.kv
<Exmaple>:
grid: grid
ScrollView:
size_hint: .5, .5
GridLayout:
id: grid
size_hint_y: None
height: self.minimum_height
width: self.minumum_width
cols: 2
.py
class Example(FloatLayout):
grid = ObjectProperty(None)
def button_cb(self):
print('Button has been pressed!')
def __init__(self):
super(Example, self).__init__()
for i in range(5):
l=Label(text='This is some text: ')
b=Button(text='Click me!', on_press=button_cb)
self.grid.add_widget(l)
self.grid.add_widget(b)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
