Can't see Window.Property when in control list
#1
Hi,

I've noticed that I don't seem to be able to access Window.Properties while building list contents (ie in <itemlayout> or <focusedlayout>.

Instead I have to tag the same property onto each item in the list.

Is this a deliberate feature or am I doing it wrong?
Reply
#2
Deliberate: The only context listitem's have is themselves. i.e. you can access ListItem.* and that's it.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#3
Fair enough, it's mildly frustrating but can be worked around once it's known. Is there a reason for this?
Reply
#4
If it's deliberate, there's a reason. The reason is simple: The listitem's pull their information from the listitem object, as this allows a far more efficient generation of the information in the list. There's no particular reason that they should be querying something from outside the list anyway, right?

(Note that for static content, you CAN get them to pull stuff from outside by defining the content. But from within the UI layout, it pulls it from the items (which are filled from the <content>))
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#5
(2013-11-11, 00:57)jmarshall Wrote: There's no particular reason that they should be querying something from outside the list anyway, right?

Umm. Well I'm building a static list where each item in the list contains an image that is tinted using <colordiffuse>. Every image will be the same, but the tint applied will be different.* However I don't want to hard code the image path, so I set a Window.Property in the python code.

Intuitively, I typed

Code:
<focusedlayout>
...
<texture>$INFO[Window.Property(Something.Something)]</texture>
</focusedlayout>

What I was expecting was something like variable scope, so the list can see not only it's own item properties, but also the "global" window properties. Anyway, it is what it is and there are several work arounds, so no biggie.

(2013-11-11, 00:57)jmarshall Wrote: (Note that for static content, you CAN get them to pull stuff from outside by defining the content. But from within the UI layout, it pulls it from the items (which are filled from the <content>))

Yes this is how I worked around it. But your statement suggests there are alternatives to static content. How would I build a list dynamically? From within the script? How can I manipulate a list from within a script? This is a noob question because I am a noob.

*ETA: I'm coding it differently now: Each item has a "frame" image, which is always the same. Then an image unique to the list item within the "frame". The frame is always the same and has to appear for every list item.
Reply
#6
I'm not really sure what you're trying to achieve. Perhaps if you posted the code you have and what you want (pictures are always good) then some suggestions could be made?

(Probably by other skinners rather than me - those guys know all the tricks).

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


Image
Reply
#7
Well I was assuming my question wouldn't need examples, and could be discussed in abstract terms.

So I can build my list like this:

Code:
<control type="list" id="51">
    ...
    <itemlayout>...</itemlayout>
    <focusedlayout>...</focusedlayout>
    <content>
       <item>...</item>
       ...
    </content>
</control>

That is, I'm defining the content in the xml. So this is a static list. The content is always the same.

How would I populate this list other than defining the content in xml? Using the words "static list" implies that there is a dynamic list structure, otherwise it would just be called a "list".

Perhaps what I'm thinking of is...

Code:
xbmcgui.Window(12600).getControl(51).addItem('Waffle House')
xbmcgui.Window(12600).getControl(51).addItem('Cheese Grill')
...

Is this good practice?
Reply
#8
This is how you can could it in a script:

PHP Code:
import xbmcxbmcgui

class Main:
    
def __init__self ):
        
self._container xbmcgui.Window/*some_window_id*/ ).getControl/*some_control_id*/ )
        
self._listItems = []

    
def onInitself ):
        
self.createListItems()
        
self.fillContainer()

    
def createListItemsself ):
        for 
x in range 0):
            
item xbmcgui.ListItem()
            
item.setLabel"Label %d" )
            
self._listItems.appenditem )

    
def fillContainerself ):
        
self._container.reset()
        for 
item in self._listItems:
            
self._container.addItemitem )

if ( 
__name__ == "__main__" ):
    
Main() 

You may need your own window xml for this but I don't remember exactly. But there is another way now, look here.
Image
Reply
#9
That looks like a robust bit of code!

But I'm in two minds about this. The normal mechanism in weather plugins seems to be to add a raft of window properties and then build the list in xml using <content>. You have to make a few assumptions about how many items there will be in the list and you have to do a little fudging, as my ealier posts in this thread show.

But if I do start manipulating the list from within python then I have to assume that that control with that id exists (and it's the right one). Essentially I'm coding skin dependence into something that perhaps shouldn't be.

Anyway its an option on the table. Cheers.
Reply
#10
I'm pretty sure my code from above does work only if you create your own window xml dialog in python, you can't grab a control from e.g. home.xml and fill it. However with the new method introduced in Gotham you can, so I would recommend reading about it.
Image
Reply
#11
Won't getControl() allow you to grab the control?
Reply

Logout Mark Read Team Forum Stats Members Help
Can't see Window.Property when in control list0