Can't get label2 to display
#1
I'm working on my first AddOn. Everything works so far, with one exception: I would like to display additional information for each listitem. Much like the episode count in the list of tvshows. But I can't get that to work.

I took all the functionality out of the plugin to have the simplest possible code to present here:
Code:
import sys
import xbmc, xbmcgui, xbmcplugin
import xbmcaddon

# plugin handle
handle = int(sys.argv[1])

# utility functions
def addDirectoryItem(name, isFolder=True, parameters={}, url='',icon='',label2='Bla'):
    ''' Add a list item to the XBMC UI.'''
    li = xbmcgui.ListItem(label=name,label2=label2,iconImage=icon)
    if url=='':
        url = sys.argv[0] + '?' + urllib.urlencode(parameters)
    return xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=li, isFolder=isFolder)


# UI builder functions
def show_root_menu():
    addDirectoryItem(name='Something',    url='videodb://2/2/1/1',isFolder=True, label2='Add. info')
    addDirectoryItem(name='Something else',    url='videodb://2/2/2/1',isFolder=True, label2='Other info')

    xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
    
ok = show_root_menu()
I've tried several thing such as setting a sortorder or the label2Mask, but nothing helped.
I have even modified the ViewsFileMode.xml of Confluence by adding some decorations around $INFO[ListItem.Label] and $INFO[ListItem.Label2] in order to make sure both are actually referenced in the skin. But whatever I tried, the value of ListItem.Label2 was empty in the skin.
What am I doing wrong?
Reply
#2
No ideas?

Maybe someone can point me to a video plugin that uses label2 to display information? Then I can try to get it to work from there...
Reply
#3
I also need this functionality... I need to access Label2 inside a skin... has anyone gotten this to work?
Reply
#4
(2013-09-05, 16:31)myce Wrote: I'm working on my first AddOn. Everything works so far, with one exception: I would like to display additional information for each listitem. Much like the episode count in the list of tvshows. But I can't get that to work.

I took all the functionality out of the plugin to have the simplest possible code to present here:
Code:
import sys
import xbmc, xbmcgui, xbmcplugin
import xbmcaddon

# plugin handle
handle = int(sys.argv[1])

# utility functions
def addDirectoryItem(name, isFolder=True, parameters={}, url='',icon='',label2='Bla'):
    ''' Add a list item to the XBMC UI.'''
    li = xbmcgui.ListItem(label=name,label2=label2,iconImage=icon)
    if url=='':
        url = sys.argv[0] + '?' + urllib.urlencode(parameters)
    return xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=li, isFolder=isFolder)


# UI builder functions
def show_root_menu():
    addDirectoryItem(name='Something',    url='videodb://2/2/1/1',isFolder=True, label2='Add. info')
    addDirectoryItem(name='Something else',    url='videodb://2/2/2/1',isFolder=True, label2='Other info')

    xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
    
ok = show_root_menu()
I've tried several thing such as setting a sortorder or the label2Mask, but nothing helped.
I have even modified the ViewsFileMode.xml of Confluence by adding some decorations around $INFO[ListItem.Label] and $INFO[ListItem.Label2] in order to make sure both are actually referenced in the skin. But whatever I tried, the value of ListItem.Label2 was empty in the skin.
What am I doing wrong?

in my experience, label2 won't work for folder items.
for file items (isFolder=False) it should work fine.
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
#5
(2013-09-20, 22:00)ronie Wrote: in my experience, label2 won't work for folder items.
for file items (isFolder=False) it should work fine.

Yes, but this is only half the truth.
Label2's value can't be set directly, it is only shown (and auto selected) when it matches contextual the current in use sort method. E.g. on an video or movie ListItem the date as label2 is only shown when sorted by date. Same with Rating, Size and so on.

Sadly, the reason you mentioned is another requirement (it needs to have isFolder=False set) - but this really needs to be changed. I would be more than happy if you (ronie) could start an internal discussion if this requirement (still) makes sense for plugins. (Little bit offtopic but the same problem) Same with InfoLabels and/or available content-types: Some are only valid on non-folder items. If you need reasons or examples, just ping me.

regards,
sphere
My GitHub. My Add-ons:
Image
Reply
#6
Hmmm, the isFolder=False is a problem for me.
Why does it work for TVShows? They are listed as "Showname 99 Episodes" with the episode count right aligned. So I assume it comes from label2. But the list of shows contains folders, not files.
Reply
#7
(2013-09-27, 15:26)myce Wrote: Hmmm, the isFolder=False is a problem for me.
Why does it work for TVShows? They are listed as "Showname 99 Episodes" with the episode count right aligned. So I assume it comes from label2. But the list of shows contains folders, not files.

i works in xbmc, just not in python addons.
it could be a bug or maybe no one ever cared to add this functionality for python addons.
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
#8
In the repository you can see also the version of each plugin right aligned..

I have installed many plugins trying to find someone that uses that approach but until now I only spot the label2 on the repository..

ronie, please consider propose the ideia for the team.. or maybe I have to compile the xbmc on my own and trying to do some pull request for this.. I think that can be worth for the plugins like livestreams because you can be show the availability of the streams before the user try to open..

Regards
Reply
#9
(2013-09-28, 00:16)ronie Wrote:
(2013-09-27, 15:26)myce Wrote: Hmmm, the isFolder=False is a problem for me.
Why does it work for TVShows? They are listed as "Showname 99 Episodes" with the episode count right aligned. So I assume it comes from label2. But the list of shows contains folders, not files.

i works in xbmc, just not in python addons.
it could be a bug or maybe no one ever cared to add this functionality for python addons. 
 I also have this issue. Label2 dont get any data when using it with plugin and isFolder=True.
Is there a workaround it ?
Reply
#10
I don't even get Label2 populating when isFolder=False. Is this doable now?

I'm working on AutoWidget, and have a folder of files (though doesn't seem to matter if I call them "files" or "videos"). I've tried using ListItem.setLabel2(...) and also by setting it as a key in the "info" dictionary.

I can't get Label2 to populate, no matter what I do.
Reply
#11
I made a PR#16705 that fixes this issue, but it not accepted yet.
My addons: Gismeteo
Reply

Logout Mark Read Team Forum Stats Members Help
Can't get label2 to display0