Вот соответствующий код kv:
Код: Выделить всё
:
BoxLayout:
id: mainBox
BoxLayout:
orientation: 'vertical'
canvas:
Color:
rgba: 0.16, 0.11, 0, 1 # brownish color
Rectangle:
pos: self.pos
size: self.size
TabbedPanel:
id: tp
do_default_tab: False
TabbedPanelItem:
id: tab_1
text: 'Tab1R'
on_release: app.showTab1R()
ListView:
id: tab1_list
orientation: 'vertical'
:
title: '2024/12/20 22:00 '
BoxLayout:
orientation: 'vertical'
Label:
text: 'Type 1'
text_size: self.width, None
Label:
text: 'Content 3'
text_size: self.width, None
:
Accordion:
id: accordyN
orientation: 'vertical'
AccordionItem:
title: '2024/12/20 00:00 '
BoxLayout:
orientation: 'vertical'
size_hint_y: None
# height: self.minimum_height
# height: type_label.height + content_label.height
valign: 'top'
Label:
id: type_label
text: 'Type 1'
text_size: self.size
halign: 'left'
valign: 'top'
Label:
id: content_label
text: 'Content 1'
text_size: self.size
halign: 'left'
valign: 'top'
AccordionItem:
title: '2024/12/20 09:00 '
BoxLayout:
orientation: 'vertical'
Label:
text: 'Type 1'
text_size: self.width, self.height
Label:
text: 'Content 2'
text_size: self.width, self.height
В моем коде Python я каким-то образом необходимо получить доступ к Аккордеону, чтобы добавить к нему виджеты. Вот мой код, который не работает:
Код: Выделить всё
...
def showTab1R(self):
self.updateList(None)
def updateList(self):
entry = ListItem(title='2024/12/20 22:00 ')
mainBox.accordyN.add_widget()
Подробнее здесь: https://stackoverflow.com/questions/788 ... -accordion