PDA

View Full Version : how to fill list


martingu1979
2008-11-24, 14:24
hi!

I have a grouplist defined in a windowxml file like this:

<control type="grouplist" id="1210">
<description>Categories</description>
<posx>80</posx>
<posy>60</posy>
<width>250</width>
<height>300</height>
<itemgap>10</itemgap>
<pagecontrol>25</pagecontrol>
<orientation>vertical</orientation>
<usecontrolcoords>false</usecontrolcoords>
<visible>true</visible>
<onup>1210</onup>
<ondown>1210</ondown>
<onleft>1210</onleft>
<onright>1210</onright>
</control>


I have tried to dynamically fill this control from a script like this:

self.list = self.getControl(1210)
for curItem in itemlist:
item = xbmcgui.ListItem(curItem['name'])
self.list.addItem(item)


It does not work, my xbox just stops responding.

When I dynamically create a "normal list" inside the script, the code from above works:

self.list = xbmcgui.ControlList(200, 150, 300, 400)
self.addControl(self.list)


But I do not want to have to create the list inside the script because I want to have a grouplist.

So my question is: how can I dynamically fill a list which is already defined in a xml?
Or, alternatively, how can I create a grouplist from a script? I only can find ControlList in the pythonLib dir but nothing like a ControlGroupList...

Thanks in advance for your help!!!

Nuka1195
2008-11-24, 15:00
grouplist's take controls not listitems. probably why it fails.

martingu1979
2008-11-24, 15:47
hm, did not work. here's my code:

def onInit(self):
# Put your List Populating code/ and GUI startup stuff here
print 'NewsOverview::onInit()'

self.list = self.getControl(1510)
self.addControl(self.list)
self.setFocus(self.list)

y=50
for comp in comps:
print str(comp['id']) + ': ' + comp['title']
item = xbmcgui.ControlButton(100, y, 250, 20, comp['title'])
item.setProperty("id", str(comp['id']))
y+=50
self.list.addItem(item)



anything wrong here? could it be that I have to use something different than 'self.list'?

Thanks!!!

Nuka1195
2008-11-24, 18:29
until grouplists are added to python natively and an addControl() method for it, you can't.