PDA

View Full Version : Anyone with a practical example of SetItems()?



DPK
May 15th, 2009, 04:45 AM
I can't quite seem to get the List class to behave nicely with the SetItems function. Anyone have a short example on how it should be appropriately be used and how to add items to a control group list using python. I'm defining a list that is customizable by local user conditions and not a remote feed. The user basically decides what's in the list and the list is generated accordingly with varying length (dynamic). The API docs are of no help:

http://developer.boxee.tv/python-api-reference/#List


SetItems
void SetItems(ListItems list)
Loads the list with items.


It sets a list with items? O'rly? :rolleyes: I've been trying to reverse engineer the issue by delving into xbmc code, but am not getting anywhere fast.

DPK
May 15th, 2009, 01:35 PM
Ok, well this sorta works... warning it's kind of not the prettiest api solution as I gave up trying to use SetItems...

self = xbmcgui.Window(14001)
glist = xbmcgui.ControlList(300, 206, 900, 400, 'font21', 'white')
self.addControl(glist)
glist.addItem("Item 1")
glist.addItem("Item 2")
glist.addItem("Item 3")

That will get you an initial (extremely basic) list generated to screen using xbmc controls.

idan
May 16th, 2009, 05:01 AM
please try this


socket = urllib.urlopen( "http://something.com" )
result = socket.read()
socket.close()
items = mc.ListItems()
result = result.split("\n")
for line in result:
item = mc.ListItem(mc.ListItem.MEDIA_VIDEO_CLIP)
item.SetLabel(line)
item.SetPath(partofsomething)
items.append(item)
mc.GetWindow(14000).GetList(140).SetItems(items)

DPK
May 16th, 2009, 05:18 AM
Is it possible to set Label2 data too using that same methodology? Don't know if it's supported by the API.

Thanks for the great example!

idan
May 16th, 2009, 02:48 PM
not possible. but you can set description.

DPK
May 17th, 2009, 06:43 AM
not possible. but you can set description.

The only reason I ask is because the weather app relies on Label2 to provide info at a glance whether radar images are enabled or not. Else it's just a big long list that you have to scroll through and select/hover on to find out if something is enabled.

xmcnuggetx
May 21st, 2009, 12:22 PM
does this work on windows? my code stops after the mc.ListItems() with an error in the boxee log like this:
ERROR: CThread::staticThread : Access violation at 0x1e071250: Reading location 0x00000048


please try this


socket = urllib.urlopen( "http://something.com" )
result = socket.read()
socket.close()
items = mc.ListItems()
result = result.split("\n")
for line in result:
item = mc.ListItem(mc.ListItem.MEDIA_VIDEO_CLIP)
item.SetLabel(line)
item.SetPath(partofsomething)
items.append(item)
mc.GetWindow(14000).GetList(140).SetItems(items)

xmcnuggetx
May 21st, 2009, 06:45 PM
.. and boxee executable remains running when I exit.


does this work on windows? my code stops after the mc.ListItems() with an error in the boxee log like this:
ERROR: CThread::staticThread : Access violation at 0x1e071250: Reading location 0x00000048

DPK
May 21st, 2009, 07:18 PM
I'm having the same problem and am trying a work around. We could make this into a race and see who finds a solution first! lol

My solutions tend to involve a combination of boxee api and xbmc api. :P I'll keep you posted as I probably won't sleep tonight until I can get this to work.

Note that if you re-arrange the code so that:

item = mc.ListItem(mc.ListItem.MEDIA_PICTURE)

...runs before mc.ListItems, it will fail as well. I'm beginning to think all the List<whatever> api does on Windows is throw access violations.

DPK
May 21st, 2009, 08:59 PM
Note: I just received word that this won't work on Windows as the API is not officially support on that version of boxee. It will be supported when the new version is released in June.

That answers that.

56Killer
May 22nd, 2009, 05:45 AM
Is there any way to set the label and path of the items from two diferent lists.

socket = urllib.urlopen( "http://something.com" )
result = socket.read()
socket.close()
items = mc.ListItems()
result = result.split("\n")
for line in result:
item = mc.ListItem(mc.ListItem.MEDIA_VIDEO_CLIP)
item.SetLabel(line)

path = path.split("\n")
for line in path:
item.SetPath(line)
items.append(item)
mc.GetWindow(14000).GetList(140).SetItems(items)

Something like that.