Skip to content

Components Expansion Panel

KivyMD edited this page Feb 25, 2020 · 12 revisions

expansion_panel.gif

Example of using MDExpansionPanel:

from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout

from kivymd.app import MDApp
from kivymd import images_path
from kivymd.uix.expansionpanel import MDExpansionPanel, MDExpansionPanelOneLine

KV = '''
<Content>
    size_hint_y: None
    height: self.minimum_height

    TwoLineIconListItem:
        text: "(050)-123-45-67"
        secondary_text: "Mobile"

        IconLeftWidget:
            icon: 'phone'


Screen:

    BoxLayout:
        orientation: "vertical"

        MDToolbar:
            title: "Expansion panel"
            elevation: 10

        ScrollView:

            MDList:
                id: box
'''


class Content(BoxLayout):
    pass


class Test(MDApp):
    def build(self):
        return Builder.load_string(KV)

    def on_start(self):
        for i in range(10):
            self.root.ids.box.add_widget(
                MDExpansionPanel(
                    size_hint_y=None,
                    height=72,
                    icon=f"{images_path}kivymd_logo.png",
                    content=Content(),
                    panel_cls=MDExpansionPanelOneLine(
                        text="Text",
                        secondary_text="Secondary text",
                        tertiary_text="Tertiary text",
                    )
                )
            )


Test().run()
Clone this wiki locally