kivymd / KivyMD

KivyMD is a collection of Material Design compliant widgets for use with Kivy, a framework for cross-platform, touch-enabled graphical applications. https://youtube.com/c/KivyMD https://twitter.com/KivyMD https://habr.com/ru/users/kivymd https://stackoverflow.com/tags/kivymd
https://kivymd.readthedocs.io
MIT License
2.14k stars 655 forks source link

MDExpansionPanel without async kivy unexpected behaviour with 100 widgets #1696

Closed Sahil-pixel closed 1 month ago

Sahil-pixel commented 1 month ago

Description of the Bug

Your text when no of widgets is 10 or some thing then it works fine , i have tested 100 widgets it is not behaving as expected .

Screencast from 19-05-24 12:09:48 PM IST.webm

Code and Logs

import asynckivy
from kivy.animation import Animation
from kivy.lang import Builder
from kivy.metrics import dp
from kivy.uix.behaviors import ButtonBehavior

from kivymd.app import MDApp
from kivymd.uix.behaviors import RotateBehavior
from kivymd.uix.expansionpanel import MDExpansionPanel
from kivymd.uix.list import MDListItemTrailingIcon

KV = '''
<ExpansionPanelItem>

    MDExpansionPanelHeader:

        MDListItem:
            theme_bg_color: "Custom"
            md_bg_color: self.theme_cls.surfaceContainerLowColor
            ripple_effect: False

            MDListItemSupportingText:
                text: "Supporting text"

            TrailingPressedIconButton:
                id: chevron
                icon: "chevron-right"
                on_release: app.tap_expansion_chevron(root, chevron)

    MDExpansionPanelContent:
        orientation: "vertical"
        padding: "12dp", 0, "12dp", "12dp"
        md_bg_color: self.theme_cls.surfaceContainerLowestColor

        MDLabel:
            text: "Channel information"
            adaptive_height: True
            padding_x: "16dp"
            padding_y: "12dp"

        MDListItem:
            theme_bg_color: "Custom"
            md_bg_color: self.theme_cls.surfaceContainerLowestColor

            MDListItemLeadingIcon:
                icon: "email"

            MDListItemHeadlineText:
                text: "Email"

            MDListItemSupportingText:
                text: "kivydevelopment@gmail.com"

        MDListItem:
            theme_bg_color: "Custom"
            md_bg_color: self.theme_cls.surfaceContainerLowestColor

            MDListItemLeadingIcon:
                icon: "instagram"

            MDListItemHeadlineText:
                text: "Instagram"

            MDListItemSupportingText:
                text: "Account"

            MDListItemTertiaryText:
                text: "www.instagram.com/KivyMD"

MDScreen:
    md_bg_color: self.theme_cls.backgroundColor

    ScrollView:
        size_hint_x: .5
        pos_hint: {"center_x": .5, "center_y": .5}

        BoxLayout:
            size_hint_y:None
            height:self.minimum_height
            orientation:'vertical'
            id: container
            padding:'50dp'
'''

class ExpansionPanelItem(MDExpansionPanel):
    ...

class TrailingPressedIconButton(
    ButtonBehavior, RotateBehavior, MDListItemTrailingIcon
):
    ...

class Example(MDApp):
    def on_start(self):
        def set_panel_list():
            for i in range(100):
                #await asynckivy.sleep(0)
                self.root.ids.container.add_widget(ExpansionPanelItem())

        #asynckivy.start(set_panel_list())
        set_panel_list()

    def build(self):
        self.theme_cls.theme_style = "Dark"
        return Builder.load_string(KV)

    def tap_expansion_chevron(
        self, panel: MDExpansionPanel, chevron: TrailingPressedIconButton
    ):
        Animation(
            padding=[0, dp(12), 0, dp(12)]
            if not panel.is_open
            else [0, 0, 0, 0],
            d=0.2,
        ).start(panel)
        panel.open() if not panel.is_open else panel.close()
        panel.set_chevron_down(
            chevron
        ) if not panel.is_open else panel.set_chevron_up(chevron)

Example().run()

Screenshots

Add images to explain us this bug. Paste urls here.

Remove this section if no images here

Versions

HeaTTheatR commented 1 month ago

https://kivymd.readthedocs.io/en/latest/components/expansionpanel/#use-with-scrollview

Sahil-pixel commented 1 month ago

please run this code and see . widgets are overlapped

HeaTTheatR commented 1 month ago

Carefully study the example from the documentation

T-Dynamos commented 1 month ago

Closing as asynckivy was used in first place to tackle that.