Skip to content

Commit

Permalink
Fix Enabling/Disabling MDTextField (#1651) (#1652)
Browse files Browse the repository at this point in the history
  • Loading branch information
ikus060 committed Mar 22, 2024
1 parent 1cc2f02 commit 0cb5697
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
78 changes: 78 additions & 0 deletions kivymd/tests/list/test_disable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
from kivy.clock import Clock
from kivy.core.clipboard import Clipboard
from kivy.input.providers.mouse import MouseMotionEvent
from kivy.lang.builder import Builder

from kivymd.app import MDApp

KV = """
MDScreen:
MDBoxLayout:
orientation: 'vertical'
MDListItem:
id: item1
MDListItemLeadingIcon:
icon: "account"
MDListItemHeadlineText:
text: "Headline1"
MDListItemSupportingText:
text: "Supporting text"
MDListItemTertiaryText:
text: "Tertiary text"
MDListItemTrailingCheckbox:
MDListItem:
id: item2
MDListItemHeadlineText:
text: "Headline2"
MDListItemSupportingText:
text: "Supporting text"
MDListItemTertiaryText:
text: "Tertiary text"
MDListItem:
id: item3
MDListItemHeadlineText:
text: "Headline3"
MDListItem:
id: item4
"""


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

def on_start(self):
def _enabled(*args):
self.root.ids.item1.disabled = False
self.root.ids.item2.disabled = False
self.root.ids.item3.disabled = False
self.root.ids.item4.disabled = False
self.stop()

def _disable(*args):
self.root.ids.item1.disabled = True
self.root.ids.item2.disabled = True
self.root.ids.item3.disabled = True
self.root.ids.item4.disabled = True
Clock.schedule_once(_enabled, 1)

super().on_start()
Clock.schedule_once(_disable, 1)


TestDisableList().run()
1 change: 1 addition & 0 deletions kivymd/uix/list/list.kv
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
} \
[len(text_container.children)]
on_disabled:
if leading_container.children: \
leading_container.children[0].disabled = args[1]


Expand Down

0 comments on commit 0cb5697

Please sign in to comment.