Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Enabling/Disabling MDTextField (#1651) #1652

Merged
merged 1 commit into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading