LIst Container static content ... cannot access list items from python

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
cybersayo Offline
Junior Member
Posts: 10
Joined: Sep 2010
Reputation: 0
Post: #1
I'm using List Container with static content as dropdown list for holding a list of options.
But, from within python, I cannot access list items?!
For dynamic populated list there is no problem, since I'm using this, but this is the first time that I need to access items of static content list.

For example...

...

Code:
<content>
              <item id="0">
                <label>$ADDON[script.tc 2069]</label>
                <onclick>-</onclick>
                <visible>true</visible>
                <property name="recure_type">once</property>
              </item>
              <item id="1">
                <label>$ADDON[script.tc 2065]</label>
                <onclick>-</onclick>
                <visible>true</visible>
                <property name="recure_type">daily</property>
              </item>

...

In python script I have method which selects item on this list based from the data from database.

Code:
def select_list_item_by_property(self,controlId,propertyName,propertyValue):
        listControl = self.getControl(controlId)
        for itemIndex in range(0,listControl.size()):
            listItem = listControl.getListItem(itemIndex)
            listItemPropertyValue = listItem.getProperty(propertyName)
            if propertyValue == listItemPropertyValue:
                listControl.selectItem(itemIndex)

But listControl.size() return 0 (zero) for this list.

Anybody have a clue??
find quote
pieh Offline
Team-XBMC Member
Posts: 664
Joined: Aug 2010
Reputation: 13
Location: Poland
Post: #2
Items (and items-related members/methods) in python controllist are only those that were created in python. What's more they will be "visible" only in one controllist instance:

Code:
control = self.getControl(LIST_ID)
control.addItem("item #1")
print control.size() #will print "1"
#creating new controllist instance
control2 = self.getControl(LIST_ID)
print control2.size() #will print "0" because item was added to other instance of controllist

Obviously this could be improved - patches welcome.

Always read the XBMC online-manual, FAQ and search the forums before posting.
Do NOT e-mail Team-XBMC members asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting, make sure you read this first

My previous forum/trac nickname: grajen3
find quote