Dynamically generating list items and displaying them in a skin
#1
I need a bit of help,

I am trying to work out how to create a set of list items in an addon and then subsequently show them in a skin. Can anyone help?

Here is an example from the skin:

Code:
<include name="Plexbmc_Shelf">
    <control type="group" description="PLEXBMC">
      <control type="label" description="Header">
        <visible>Control.IsVisible(311)</visible>
        <include>RecentlyAdded_Header</include>
        <label>$INFO[Container(311).ListItem.Property(ItemType)]</label>
      </control>
      <control type="label" description="Label">
        <visible>Control.HasFocus(311)</visible>
        <include condition="!Skin.HasSetting(VerticalHome)">Horizontal_Label_Commons</include>
        <include>RecentlyAdded_Label</include>
        <label>$INFO[Container(311).ListItem.Label]</label>
      </control>
      <control type="fixedlist" id="311" description="Movies PLEXBMC">
        <visible>!IsEmpty(Window(Home).Property(Plexbmc.LatestMovie.1.Path))</visible>
        <visible>StringCompare(Container(300).ListItem.Property(type),movie)</visible>
        <onright>311</onright>
        <onup>300</onup>
        <onleft condition="Skin.HasSetting(VerticalHome)">300</onleft>
        <onleft condition="!Skin.HasSetting(VerticalHome)">311</onleft>
        <ondown condition="Control.IsVisible(312)">312</ondown>
        <ondown condition="!Control.IsVisible(312)">300</ondown>
        <include condition="!Skin.HasSetting(VerticalHome)">Horizontal_Shelf_Commons</include>
        <include>RecentlyAdded_Posters</include>
        <content>
          <item id="1" description="Movies">
            <visible>!IsEmpty(Window(Home).Property(Plexbmc.LatestMovie.1.Path))</visible>
            <visible>StringCompare(Container(300).ListItem.Property(uuid),Window(Home).Property(Plexbmc.LatestMovie.1.uuid))</visible>
            <label>$INFO[Window(Home).Property(Plexbmc.LatestMovie.1.Title)][COLOR=White]$INFO[Window(Home).Property(Plexbmc.LatestMovie.1.Year), • ]$INFO[Window(Home).Property(Plexbmc.LatestMovie.1.Rating), • ]$INFO[Window(Home).Property(Plexbmc.LatestMovie.1.Duration), • , $LOCALIZE[31297]][/COLOR]</label>
            <thumb>$INFO[Window(Home).Property(Plexbmc.LatestMovie.1.Thumb)]</thumb>
            <property name="ItemType">$LOCALIZE[31961]</property>
            <onclick>PlayMedia($ESCINFO[Window(Home).Property(Plexbmc.LatestMovie.1.Path)])</onclick>
          </item>
          <item id="2" description="Shortcut2">
            <visible>!IsEmpty(Window(Home).Property(Plexbmc.LatestMovie.2.Path))</visible>
            <visible>StringCompare(Container(300).ListItem.Property(uuid),Window(Home).Property(Plexbmc.LatestMovie.2.uuid))</visible>
            <label>$INFO[Window(Home).Property(Plexbmc.LatestMovie.2.Title)][COLOR=White]$INFO[Window(Home).Property(Plexbmc.LatestMovie.2.Year), • ]$INFO[Window(Home).Property(Plexbmc.LatestMovie.2.Rating), • ]$INFO[Window(Home).Property(Plexbmc.LatestMovie.2.Duration), • , $LOCALIZE[31297]][/COLOR]</label>
            <thumb>$INFO[Window(Home).Property(Plexbmc.LatestMovie.2.Thumb)]</thumb>
            <property name="ItemType">$LOCALIZE[31961]</property>
            <onclick>PlayMedia($ESCINFO[Window(Home).Property(Plexbmc.LatestMovie.2.Path)])</onclick>
          </item>
          <item id="3" description="Shortcut3">
            <visible>!IsEmpty(Window(Home).Property(Plexbmc.LatestMovie.3.Path))</visible>
            <visible>StringCompare(Container(300).ListItem.Property(uuid),Window(Home).Property(Plexbmc.LatestMovie.3.uuid))</visible>
            <label>$INFO[Window(Home).Property(Plexbmc.LatestMovie.3.Title)][COLOR=White]$INFO[Window(Home).Property(Plexbmc.LatestMovie.3.Year), • ]$INFO[Window(Home).Property(Plexbmc.LatestMovie.3.Rating), • ]$INFO[Window(Home).Property(Plexbmc.LatestMovie.3.Duration), • , $LOCALIZE[31297]][/COLOR]</label>
            <thumb>$INFO[Window(Home).Property(Plexbmc.LatestMovie.3.Thumb)]</thumb>
            <property name="ItemType">$LOCALIZE[31961]</property>
            <onclick>PlayMedia($ESCINFO[Window(Home).Property(Plexbmc.LatestMovie.3.Path)])</onclick>
          </item>
          <item id="4" description="Shortcut4">
            <visible>!IsEmpty(Window(Home).Property(Plexbmc.LatestMovie.4.Path))</visible>
            <visible>StringCompare(Container(300).ListItem.Property(uuid),Window(Home).Property(Plexbmc.LatestMovie.4.uuid))</visible>
            <label>$INFO[Window(Home).Property(Plexbmc.LatestMovie.4.Title)][COLOR=White]$INFO[Window(Home).Property(Plexbmc.LatestMovie.4.Year), • ]$INFO[Window(Home).Property(Plexbmc.LatestMovie.4.Rating), • ]$INFO[Window(Home).Property(Plexbmc.LatestMovie.4.Duration), • , $LOCALIZE[31297]][/COLOR]</label>
            <thumb>$INFO[Window(Home).Property(Plexbmc.LatestMovie.4.Thumb)]</thumb>
            <property name="ItemType">$LOCALIZE[31961]</property>
            <onclick>PlayMedia($ESCINFO[Window(Home).Property(Plexbmc.LatestMovie.4.Path)])</onclick>
          </item>

it's basically the <item id="1" description="Movies"> bits that I want to generate in code and then some how display in the

I think the subtitle addon does somethng similar, and I found:

Code:
listitem = xbmcgui.ListItem(label=_( languageTranslate(item["language_name"],0,5)),
                                        label2=item["filename"],
                                        iconImage=item["rating"],
                                        thumbnailImage=item["language_flag"]
                                       )

But I have no idea how to acually pass this to the skin?
Get and request your ClearLOGOs / ClearART / TV Thumbs / Season Thumbs / Music ClearLOGOs / cdART / Artist Backgrounds / CD Covers from fanart.tv
Reply
#2
you'll have to set the window properties in your addon.
Code:
xbmcgui.Window(10000).setProperty("Plexbmc.LatestMovie.1.Title", 'whatever')

you can have a look at the skin widgets service for more examples.
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#3
Hi ronie, thaks for replying, I think you misunderstand what I am trying to do, or I misunderstand something about your reply, the window property is already set:

Code:
WINDOW.setProperty("Plexbmc.LatestMovie.%s.Title" % movieCount, media.get('title','Unknown').encode('UTF-8'))

And then the skin code above will display the item, however, we want to, in effect, remove the skin code and get the plugin to directly output the list items.

The reason for this is the end user might have say 4 sections for movies (lets say Movies, Kids movies, adult movies, home movies), so what we are currently doing is getting the last 25 items in each section, which creates a list with 100 items in it each item has a sectionid attrbute, so in effect when you are in the kids movies section it loops through the list and says "is this item in the kids movies section? If yes, display it", this would work, but it would mean that the skin xml would need 100 items, and thats assuming the user has 4 sections, they might have 1, they might have 10, if they had 10 and the skin only went up to 100 then the remaining 6 sections would be empty, and having to loop though every one and do a check is taxing, it would be much more efficient/actully work if the plugin could display these itself as it knows what items are in the particular section.

This is for the shelf section on the home screen if you look at the Amber skin screenshots http://forum.xbmc.org/showthread.php?tid=172629 its when you go through each section, the shelf items that get displayed

Or are you saying that using xbmcgui.Window(10000).setProperty("Plexbmc.LatestMovie.1.Title", 'whatever') instead would directly output them rather than setting a variable to be used by te skin?
Get and request your ClearLOGOs / ClearART / TV Thumbs / Season Thumbs / Music ClearLOGOs / cdART / Artist Backgrounds / CD Covers from fanart.tv
Reply
#4
Martijn has suggested what I'm after is something like the built in recently added list which is created dynamically, which in effect is what I am recreating, the difference is the items don't come from the library but from an xml feed, if that helps?
Get and request your ClearLOGOs / ClearART / TV Thumbs / Season Thumbs / Music ClearLOGOs / cdART / Artist Backgrounds / CD Covers from fanart.tv
Reply
#5
so either if there are only 10 or 500 it auto fills like normal library view
Read/follow the forum rules.
For troubleshooting and bug reporting, read this first
Interested in seeing some YouTube videos about Kodi? Go here and subscribe
Reply
#6
I think I figured it out Big Grin will post back if it works
Get and request your ClearLOGOs / ClearART / TV Thumbs / Season Thumbs / Music ClearLOGOs / cdART / Artist Backgrounds / CD Covers from fanart.tv
Reply
#7
*edit*
Will ask this in it's own thread as it's unrelated
Get and request your ClearLOGOs / ClearART / TV Thumbs / Season Thumbs / Music ClearLOGOs / cdART / Artist Backgrounds / CD Covers from fanart.tv
Reply

Logout Mark Read Team Forum Stats Members Help
Dynamically generating list items and displaying them in a skin0