KivyMD | List Item print its "text" on_press

Viewed 795

How can I code a OneLineListItem in KivyMD to print its "text" on a console? I came up with something like this:

[...]
item = OneLineListItem(text="DEMO", on_press= lambda x: ??????? )
list.add_widget(item)
[...]

I would like to have the word "DEMO" printed on the console after pressing on Item.

1 Answers

You can do it like below:

item = OneLineListItem(text="DEMO", on_press=lambda x: print(x.text))
Related