Kodi Community Forum

Full Version: how to update Progress control inside a list that was created using Python Addon
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a python script add-on based on plugin.video.example. Here I am basically providing a Custom XML page which has different panels and lists. I hide and show panels and lists depending upon what the user is trying to do.

The page in question is much similar to "MyPVRChannels.xml". It has a 'List' for Channels and Each list item has the following type of controls - Labels, Images and progress bar. I'm able to populate all controls (except Progress bar) from Python by creating Properties for each list item as shown below:

list_item = xbmcgui.ListItem(label=row['channelName'])
list_item.setProperty('nowPlaying', row['Title'])
list_item.setProperty('imageUrlForNowPlaying', row['ImageURL'])

and then retrieving those properties in XML file for matching controls:
...
<info>ListItem.Label</info>
...
 <info>ListItem.Property("nowPlaying")</info>
...
<info>ListItem.Property("imageUrlForNowPlaying")</info>

But this method does not work for setting the Progress on Progress Bar.

I am able to set the Progress of a Progress bar if it is not a part of the List and instead has a unique control ID. In that case I get the control via its ID and then set Percent as follows:

ctrlProgressBar.setPercent(<intProgressValue>)

I imaging I'll need to do something similar for the progress bar that is inside the list. But the problem is even if I assign it a unique control ID, I will still have multiple controls with that ID.

I tried iterating through the List to get list Item, but once I have list_item it does not have a method called list_item.getControl(ID), so I am not able to directly gain access to the progress bar.

I do see that MyPVRChannel is able to populate the ProgressBar inside the list under the TV channel lineup, so it is possible.

Please advice on how to get access to ProgressBar that is placed inside a List.

Thanks,
haven't tested it, but something like this might work:

xml:
<control type="progress">
   <left>0</left>
   <top>0</top>
   <height>50</height>
   <width>400</width>
   <info>ListItem.Property(ProgressPercent)</info>
</control>

to set the initial value:
python:
list_item.setProperty('ProgressPercent', '50')

to update the value:
python:

list_item = cList.getListItem(6)
list_item.setProperty('ProgressPercent', '75')
Thanks Ronnie. That was it, I'm able to set the progress bar using this method.

I tried the same thing with a different key 'Progress' and that same method doesn't work. I guess there is something special about 'ProgressPercent' that gets processed correctly and updates the progress bar.

I can move forward now, I spent almost a day researching and trying different things, for some reason didn't think the key mattered. But clearly it did. Thanks again!!