Answer the question
In order to leave comments, you need to log in
How to make vertical buttons in kivy accordion?
The code:
# -*- coding: utf8 -*-
from kivy.uix.accordion import Accordion, AccordionItem
from kivy.uix.label import Label
from kivy.app import App
from kivy.uix.button import Button
items = {
"razdely": [
{"text": "О жизни", "id": 1},
{"text": "О Человеке", "id": 2},
{"text": "О тесте", "id": 3}]
}
class AccordionApp(App):
def build(self):
root = Accordion(orientation='vertical')
for x in items.get('razdely'):
item = AccordionItem(title=x.get("text"))
item.add_widget(Button(text="Кнопка N1"))
item.add_widget(Button(text="Кнопка N2"))
root.add_widget(item)
return root
if __name__ == '__main__':
AccordionApp().run()
Answer the question
In order to leave comments, you need to log in
BoxLayout stick vertical where the buttons are.
From the documentation ( https://kivy.org/docs/api-kivy.uix.boxlayout.html#...
layout = BoxLayout(orientation='vertical')
btn1 = Button(text='Hello')
btn2 = Button(text='World')
layout.add_widget(btn1)
layout.add_widget(btn2)
for x in items.get('razdely'):
item = AccordionItem(title=x.get("text"))
#~ item.add_widget(Button(text="Кнопка N1"))
#~ item.add_widget(Button(text="Кнопка N2"))
#~ item.add_widget(layout)
layout = BoxLayout(orientation='vertical')
btn1 = Button(text='Hello')
btn2 = Button(text='World')
layout.add_widget(btn1)
layout.add_widget(btn2)
item.add_widget(layout)
root.add_widget(item)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question