Beginner's GUI Question
#1
Hi, new to forums but long time XBMC user. My Python is ok but I am struggling to get my head around the xbmcgui API. Trawling google has lead me to write the following (very simple) test script:

Code:
import xbmcaddon, xbmc, xbmcgui

def addMenuItem(caption, link, icon=None, thumbnail=None, folder=False):
    listItem = xbmcgui.ListItem(unicode(caption), iconImage=icon, thumbnailImage=thumbnail)
    listItem.setInfo(type="Video", infoLabels={ "Title": caption })
    return xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=link, listitem=listItem, isFolder=folder)

def endListing():
    xbmcplugin.endOfDirectory(int(sys.argv[1]))

addMenuItem('TestCaption','/')
endListing()

I was hoping this would bring up a menu screen with one option 'TestCaption' (obviously going nowhere at this stage) .

When I select my addon, I get a script failure - any help appreciated.[/code]
Reply
#2
the xbmc.log file will tell you exactly what's wrong:
- TypeError: argument "iconImage" for method "XBMCAddon::xbmcgui::ListItem" must be unicode or str
- TypeError: argument "thumbnailImage" for method "XBMCAddon::xbmcgui::ListItem" must be unicode or str
- NameError: global name 'xbmcplugin' is not defined
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#3
xbmc.log... of course there is! that is all kinds of useful - thankyou very much!

just to make sure I'm on the right track, picking up instructions from the command lines (.arg[whatever]) and then referring to 'mode' as I've seen elsewhere, feels a little hacky. Is that the recommended way? I'm working my way through the API docs but like examples and many seem to go down this route....
Reply
#4
If you don't want to go the ugly way, have a look to xbmcswift.
Have a look to any of my add-ons (see my github account) and the xbmcswift website: www.xbmcswift.com
My GitHub. My Add-ons:
Image
Reply
#5
Ha, yeah I'd rather avoid the ugly! xbmcswift looks cool - thanks for the link, I'll have a play around.
Reply

Logout Mark Read Team Forum Stats Members Help
Beginner's GUI Question0