Need help - why does my function not work - thumbnail related

  Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
cheetah05 Offline
Senior Member
Posts: 117
Joined: Feb 2007
Reputation: 1
Post: #1
Basically it's to add a video link to a list:

Code:
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 Smile)

Thanks.
(This post was last modified: 2008-10-28 04:41 by cheetah05.)
find quote
BigBellyBilly Offline
Skilled Python Coder
Posts: 900
Joined: Feb 2005
Reputation: 2
Location: UK
Post: #2
your number of parms to ListItem is incorrect, missing a label2 before giving the image.

http://xbmc.sourceforge.net/python-docs/...l#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

My Addons (myTV, T3CH Upgrader, DVDProfiler, BBCPodRadio, Comics, Football, GoogleReader, reeplay.it, Metacritic, Phonebin, FileViewer,SVN Repo Installer (contributor)) available at Box.net
(This post was last modified: 2008-10-28 18:38 by BigBellyBilly.)
find quote
cheetah05 Offline
Senior Member
Posts: 117
Joined: Feb 2007
Reputation: 1
Post: #3
Knew it was something stupid.

Thanks! - Working now.

EDIT: Now it doesn't show the "DefaultVideo.png" for some reason
(This post was last modified: 2008-10-28 19:41 by cheetah05.)
find quote