Skip to content
Advertisement

Is there a way to send a specific string to function in Kivy?

I am making a video search app, and I came across this issue and I can not solve it. The user inputs keywords and the app returns video titles based on the search results. After that the app displays the results:

JavaScript

This works perfectly and all the videos get displayed with unique titles. But I also set that it should send the videos_id based on the index, but it always sends the last one, no matter which one I click.

How could I solve this?

Advertisement

Answer

That is a common problem with defining a lambda that uses a loop index. The fix is to define another index that equals the loop index. Like this:

JavaScript

Note the j=i and the vid_list[j].

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement