Kodi Community Forum
Beginner's GUI Question - 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: Beginner's GUI Question (/showthread.php?tid=171034)



Beginner's GUI Question - newskin - 2013-08-11

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]


RE: Beginner's GUI Question - ronie - 2013-08-11

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


RE: Beginner's GUI Question - newskin - 2013-08-11

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....


RE: Beginner's GUI Question - sphere - 2013-08-12

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


RE: Beginner's GUI Question - newskin - 2013-08-12

Ha, yeah I'd rather avoid the ugly! xbmcswift looks cool - thanks for the link, I'll have a play around.