Почему при добавлении дочернего лайаута словарь ids пуст?
from kivy.app import App
from kivy.lang import Builder
timer_kv = '''
BoxLayout:
orientation: 'vertical'
minute: minute
second: second
second_100: second_100
GridLayout:
cols: 5
Label:
id: minute
text: '00'
font_size: 60
Label:
text: ':'
font_size: 60
Label:
id: second
text: '00'
font_size: 60
Label:
text: '.'
font_size: 60
Label:
id: second_100
text: '00'
font_size: 60
ScrollView:
GridLayout:
cols: 1
size_hint_y: 1, None
height: self.minimum_height
BoxLayout:
orientation: 'horizontal'
Button:
id: btn_clear
text: 'Clear'
size_hint: .3, .3
on_press: app.clearing(self.parent)
Button:
id: btn_start_or_stop
size_hint: .3, .3
text: 'Start'
on_press: app.starting_or_stopping(self.parent)
Button:
id: btn_round
size_hint: .3, .3
text: 'Round'
on_press: app.add_round(self.parent)
'''
# self.minimum_height - настройка высоты разметки на высоту дочерних виджетов
class TimerApp(App):
def build(self):
return Builder.load_string(timer_kv)
def clearing(self, instance):
pass
def starting_or_stopping(self, instance):
print(instance.ids)
def add_round(self, instance):
pass
if __name__ == '__main__':
TimerApp().run()
Ответы (1 шт):
Автор решения: Алексей Лень
→ Ссылка
Просто поменяй self.parent на root в функции кнопок: on_press: app.starting_or_stopping(root)