Kivy's Root Widget in .kv file to .py file

Viewed 100

I'm trying to make a list with some icons actions but I'm stuck with this issue. If I create the list with this code: everything works as it supposed to.

.kv file:

<ListItemsWithIcons>:
    IconLeftWidget:
        icon: '*.icns'

    IconRightWidget:
        id:del_icon
        icon: 'trash-can-outline'
        theme_text_color: "Custom"
        text_color: 1, 0, 0, 1
#        pos_hint_x: 'right'
        on_release: app.del_playlist(root)

But I need to do it from the python file. I been trying something like this:

.py file:

item = OneLineAvatarIconListItem(text=playlist_name, on_release=lambda x, item=playlist_name: print("item number", item))

icon = IconRightWidget( 
    icon='trash-can-outline',
    theme_text_color="Custom",
    text_color= (1, 0, 0, 1),
    on_release=self.del_playlist(root)
)
item.add_widget(icon)
self.root.ids.playlist.add_widget(item)

The problem is in this line: on_release=self.del_playlist(root) in the .py file. I don't know how to refer to 'root' from here.

Any help will be more than appreciated.

0 Answers
Related