Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

KivyMD | List Item print its "text" on_press

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.

like image 245
bobk810i Avatar asked Dec 18 '25 10:12

bobk810i


1 Answers

You can do it like below:

item = OneLineListItem(text="DEMO", on_press=lambda x: print(x.text))
like image 145
amras Avatar answered Dec 21 '25 02:12

amras



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!