In this video I’ll show you how to use an Accordion with Kivy and Python.
Accordions are really fun to use, and super easy to build. They’re great for creating separate panels in your app that contain different things.
You can put just about anything in an AccordionItem, text, images, buttons, anything you like!
Python Code: accordion.py
GitHub Code: accordion.py
from kivy.app import App from kivy.uix.widget import Widget from kivy.properties import ObjectProperty from kivy.lang import Builder # Designate Our .kv design file Builder.load_file('accordion.kv') class MyLayout(Widget): pass class AwesomeApp(App): def build(self): return MyLayout() if __name__ == '__main__': AwesomeApp().run()
Kivy Design Code: accordion.kv
GitHub Code: accordion.kv
<MyLayout> BoxLayout: orientation: "vertical" size: root.width, root.height Accordion: orientation: 'vertical' AccordionItem: title: "Panel 1" Image: source: 'images/aspen1.jpg' AccordionItem: title: "Panel 2" Label: text: "Panel 2 Text" font_size: 32 AccordionItem: title: "Panel 3" Image: source: 'images/aspen2.png' AccordionItem: title: "Panel 4" Label: text: "Panel 4 Text" font_size: 32
Add comment