Getting the current selection
#1
I want to get XBMC's current selection from a Python script so I can do various interesting things with the media file it points to. I've tried the following:

Code:
import xbmcgui

win = xbmcgui.Window(xbmcgui.getCurrentWindowId())

curctl = win.getFocus()
print "Type of curctl is " + type(curctl).__name__

cursel = curctl.getSelectedItem()
print "Type of cursel is " + type(cursel).__name__

label = cursel.getLabel()

But this prints to the log:

Code:
NOTICE: Type of curctl is ControlList
NOTICE: Type of cursel is NoneType

and the getLabel() call then generates an exception because obviously the type None has no getLabel() function. Why does the ControlList.getSelectedItem call return None? An item was selected when I ran the script.

Is there a different/better way for a script to get the currently selected item from the Video or Music navigation lists?
Reply


Messages In This Thread
Getting the current selection - by jhsrennie - 2012-07-02, 16:53
RE: Getting the current selection - by pieh - 2012-07-03, 10:30
RE: Getting the current selection - by ronie - 2012-09-21, 20:17
RE: Getting the current selection - by ronie - 2012-09-21, 23:19
RE: Getting the current selection - by Popeye - 2012-11-27, 23:10
RE: Getting the current selection - by belese - 2013-10-10, 16:04
RE: Getting the current selection - by tim619 - 2015-11-07, 02:18
RE: Getting the current selection - by Torben - 2016-04-02, 15:14
Logout Mark Read Team Forum Stats Members Help
Getting the current selection0