I can't seem to make MDCardSwipe work. Even the sample code lifted directly from the documentation within kivymd.uix.card does not work on my machine.
from kivy.lang import Builder
from kivy.properties import StringProperty
from kivymd.app import MDApp
from kivymd.uix.card import MDCardSwipe
KV = '''
<SwipeToDeleteItem>:
size_hint_y: None
height: content.height
MDCardSwipeLayerBox:
# Content under the card.
MDCardSwipeFrontBox:
# Content of card.
OneLineListItem:
id: content
text: root.text
_no_ripple_effect: True
MDScreen:
MDBoxLayout:
orientation: "vertical"
spacing: "10dp"
MDToolbar:
elevation: 10
title: "MDCardSwipe"
ScrollView:
scroll_timeout : 100
MDList:
id: md_list
padding: 0
'''
class SwipeToDeleteItem(MDCardSwipe):
'''Card with `swipe-to-delete` behavior.'''
text = StringProperty()
class TestCard(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.screen = Builder.load_string(KV)
def build(self):
return self.screen
def on_start(self):
'''Creates a list of cards.'''
for i in range(20):
self.screen.ids.md_list.add_widget(
SwipeToDeleteItem(text=f"One-line item {i}")
)
TestCard().run()
The above code on my machine creates the cards in a list, but there is no swipe functionality. I have also tried playing around with swipe_distance and swipe_type but have been unable to ever get the swipe functionality working.
Ran into the same problem myself.
I would advise looking at the 'end code' from the MDCardSwipe docs, run it and you'll probably have the same issue as in your original question.
You'll notice that if (on pc) you long press at the left edge and then drag the swipe functionality is there, just incredibly difficult to trigger.
I believe this is due to competition between the scrollview and the child widgets for the input, I solved the problem by adjusting scroll_timeout
.