PDA

View Full Version : Need help - why does my function not work - thumbnail related


cheetah05
2008-10-28, 05:26
Basically it's to add a video link to a list:


def AddListItem (Name, Url, Image):
if (Image == ""):
Image = "DefaultVideo.png"
else:
Image = str (os.path.join (os.getcwd (), 'images', Image))
guiListItem = xbmcgui.ListItem (Name, Image, Image)
guiListItem.setInfo (type = "Video", infoLabels = {"Title": Name})
success = xbmcplugin.addDirectoryItem (int (sys.argv[1]), Url, guiListItem)
return success


If the Image parameter is null then it displays the DefaultVideo.png image fine. But the parameter actually has an image filename input then it displays nothing.

I have checked and the image does exist in the folder: %plugin_dir%\images\. Have tried another image too just to make sure it isn't the image.

Also made sure I imported os & os.path.

What am I doing wrong? Syntax error? (This is my first hour of python :))

Thanks.

BigBellyBilly
2008-10-28, 19:33
your number of parms to ListItem is incorrect, missing a label2 before giving the image.

http://xbmc.sourceforge.net/python-docs/xbmcgui.html#ListItem

ListItem([label, label2, iconImage, thumbnailImage])

eg
listitem = xbmcgui.ListItem('Casino Royale', '[PG-13]', 'blank-poster.tbn', 'poster.tbn')

so your example should be:

guiListItem = xbmcgui.ListItem (Name, "", Image, Image)

Python will let you reference parms by name should you wish to exclude some:
eg.
guiListItem = xbmcgui.ListItem (Name, iconImage=Image, thumbnailImage=Image)


You might also want to assign a var to your images location then your func doesn't have to build it each time.
eg.
DIR_HOME = os.getcwd ()
DIR_IMAGES = os.path.join (DIR_HOME , 'images' )

then in func:
eg.
imgPath = os.path.join (DIR_IMAGES, Image)



BBB

cheetah05
2008-10-28, 20:27
Knew it was something stupid.

Thanks! - Working now.

EDIT: Now it doesn't show the "DefaultVideo.png" for some reason