Custom Attributes on a ListItem
#1
Hi all,

I'm writing a custom addon which doesn't fit into any of the standard xbmc categories (video/music etc). It's a torrent interface and there is a bunch of properties that i would like to add to a listitem and have them rendered by my interface, things like download speed, percentage and other stuff.

I've got it somewhat working by using list_item.setProperty('percentage', percentage) etc however this property is not updated. Wwhen i do a item.setLabel it will automatically and immediately be updated in the UI, my custom properties only get refreshed when the container gets focus, and when item gets focus.

My question is what makes Label different from properties, and how can i put my own attributes onto a listitem that are reflected in the UI in the same way that labels work?

Thanks
Reply
#2
not sure what the issue with setProperty() not updating is.

PHP Code:
<control type="label">
                            <
description>Day label</description>
                             <
label>$INFO[ListItem.Property(Percentage)]</label>
                        </
control

your script would change the value of the window.property, not the listitem. to do this with a regular list you would have to use static content.

PHP Code:
<content>
            <
item>
                <
label>$INFO[Window.Property(MapList.1.MapLabel.1)]</label>
                <
label2>$INFO[Window.Property(MapList.1.MapLabel2.1)]</label2>
                <
icon>$INFO[Window.Property(MapList.1.MapIcon.1)]</icon>
                
                <
property name="Percentage">$INFO[Window.Property(MapList.1.Percentage.1)]</property>
                
                <
onclick>$INFO[Window.Property(MapList.1.MapOnclick.1)]</onclick>
                <
visible>!IsEmpty(Window.Property(MapList.1.MapLabel.1))</visible>
            </
item>
     </
content

just add a bunch and hide ones not in use
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#3
So i'm not sure how that works when you are manually populating the list. I'm not sure what MapList is in that instance, how do i use that?

The code i'm referring to is https://github.com/jamielennox/xbmc-delu...lib/gui.py and whilst the list is defined in the xml file https://github.com/jamielennox/xbmc-delu...e-main.xml but i need to add the listitems based on entries on the server.

Anyway i was looking through xbmc/guilib/GUIListItem.cpp and similar and in the setLabel, setArt, etc functions there is a call to SetInvalid which later causes the list item to be reprocessed which is why they change instantly. When you look at the SetProperty method there is no SetInvalid call so the item is only processed when some other call invalidates it, which is why it would occasionally update when things like the container got focus happened.

So there are a couple of ways i can see of fixing this.
1. I'm still learning xbmc, but MapList in your example looks like a model layer. Is there some documentation on this? How do i set it from python?
2. Is there a legitimate way to invalidate a listitem from python manually? There isn't anything i can see in the python APIs. Should changing a property on a ListItem redraw the control, I would have thought so. Is there something else other than properties that i can use?
3. The way i'm currently doing it is by putting display data into properties, and then by changing label2 when something changes (not displaying label2 via UI), this invalidates the old image and redraws it with the new data. You can see this in gui.py, it works but is obviously a hack.

Thanks
Reply

Logout Mark Read Team Forum Stats Members Help
Custom Attributes on a ListItem0