Kodi Community Forum
Activating a listitem with python - Printable Version

Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
--- Thread: Activating a listitem with python (/showthread.php?tid=353166)



Activating a listitem with python - zachmorris - 2020-04-04

I have a need in my addon to select and activate a listitem in a certain condition. In python, I have been able to figure out how to select the listitem but not activate it/choose it. Here's what I've tried:

wid = xbmcgui.getCurrentWindowId()
win = xbmcgui.Window(wid)
control = win.getFocus()
control.selectItem(1) #This correctly selects the listitem
xbmc.executebuiltin('SendClick(%(current_wid)s,%(current_item)s)'%{'current_wid':wid,'current_item':control}) #Doesn't work, debug shows WARNING: Attempt to use invalid handle xxx
xbmc.executebuiltin('SendClick(%(current_wid)s,%(current_item)s)'%{'current_wid':wid,'current_item':control.getSelectedItem()}) #Doesn't work, debug shows WARNING: Attempt to use invalid handle xxx
xbmc.executebuiltin('SendClick(%(current_item)s)'%{'current_wid':wid,'current_item':control.getSelectedItem()}) #Doesn't work, debug shows WARNING: Attempt to use invalid handle xxx

Any way to accomplish what I'm trying to do?

Thanks in advance


RE: Activating a listitem with python - DimaKompot - 2020-05-18

I had the same requirement. Nothing worked for me and I ended up with JSON-RPC calls: just move the focus and select the item:
build_song_list(*bandcamp.get_album_by_url(url))
xbmc.executeJSONRPC(
'{"jsonrpc":"2.0","method":"Input.Down","id":1}')
xbmc.executeJSONRPC(
'{"jsonrpc":"2.0","method":"Input.Select","id":1}')
You can check full sourcecode on:
https://github.com/Virusmater/plugin.audio.kxmxpxtx.bandcamp


This forum uses Lukasz Tkacz MyBB addons.