Sending Image List to WindowXMLDialog from Addon
#1
I don't know if this is the correct forum but I am creating an script to retrieve Trending Movies, Tv shows etc all in one gui screen. The problem is that when I used xbmcgui.WindowDialog it took about 7 to 8 seconds to create the window but the script only takes 1 to 2 seconds to actually run and retrieve the information so I decided to try my hand on using WindowXMLDialog.

Using a preexisting xml the load up speed was a lot faster (1 - 2 sec), the issue is that I am trying to create an image list with the covers, name etc as seen bellow and have to code each control in the xml individually. Is there any way populating the xml gui file from a list instead of manually having to ceate a control for each individual item? For example in this case it would be about 80 controls that would have to be created (Cover, Movie Name, Trakt Heart, Rating, Votes, Watcher Eye, Watchers) and another 80 for TV.



Image

Thank You,
Reply
#2
sure, just create a list control in your xml file.
http://kodi.wiki/view/List_Container

in your python file, create a listitem for each item you want to display:
http://mirrors.xbmc.org/docs/python-docs...l#ListItem

then you can use the xbmcgui.ControlList().addItems() method to add all your listitems in one go:
http://mirrors.xbmc.org/docs/python-docs...t-addItems
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
Thank You, I read all that yesterday but was not able to get it to work till you laid out the steps.

Another question the list has ... dots on the left hand corner like to go back to a subfolder can that be eliminated?

Thanks again,
Reply
#4
hmm, i can't think of a reason why the '..' item would be there in the list, unless it's your addon that's adding it.

are you perhaps using some xbmcplugin code to fill the list?

a link to your addon code might make it easier to spot issues ;-)
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
It had to do with a list control just found it.

I have one more question when I hover over the images the images move left.

PHP Code:
<control type="list" id="50">
      <
description>My first list container</description>
      <
left>0</left>
      <
top>10</top>
      <
width>1150</width>
      <
height>1100</height>
      <
visible>true</visible>
      <
onup>2</onup>
      <
ondown>3</ondown>
      <
onleft>1</onleft>
      <
onright>1</onright>
      <
viewtype label="list">icon</viewtype>
      <
orientation>horizontal</orientation>
      <
pagecontrol>8</pagecontrol>
      <!-- <
autoscroll>true</autoscroll>
      <
scrolltime tween="sine" easing="out">200</scrolltime> -->
      <
itemlayout width="95" height="180">
                <
control type="image">
                        <
left>0</left>
                        <
top>3</top>
                        <
width>80</width>
                        <
height>120</height>
                        <
info>ListItem.Icon</info>
                </
control>
                <!-- <
control type="label">
                        <
left>30</left>
                        <
top>3</top>
                        <
width>430</width>
                        <
height>22</height>
                        <
font>font13</font>
                        <
aligny>center</aligny>
                        <
selectedcolor>green</selectedcolor>
                        <
align>left</align>
                        <
info>ListItem.Label</info>
                </
control>
                <
control type="label">
                        <
left>475</left>
                        <
top>3</top>
                        <
width>300</width>
                        <
height>22</height>
                        <
font>font13</font>
                        <
aligny>center</aligny>
                        <
selectedcolor>green</selectedcolor>
                        <
textcolor>grey</textcolor>
                        <
align>right</align>
                        <
info>ListItem.Label2</info>
                </
control> -->
      </
itemlayout>
      <
focusedlayout height="95" width="180">
                <
control type="image">
                        <
width>485</width>
                        <
height>29</height>
                        <
left>0</left>
                        <
top>0</top>
                        <
visible>Control.HasFocus(50)</visible>
                        <
texture>list-focus.png</texture>
                </
control>
                <
control type="image">
                        <
left>0</left>
                        <
top>0</top>
                        <
width>80</width>
                        <
height>120</height>
                        <
info>ListItem.Icon</info>
                </
control>
                <!-- <
control type="label">
                        <
left>30</left>
                        <
top>3</top>
                        <
width>430</width>
                        <
height>22</height>
                        <
font>font13</font>
                        <
aligny>center</aligny>
                        <
selectedcolor>green</selectedcolor>
                        <
align>left</align>
                        <
info>ListItem.Label</info>
                </
control>
                <
control type="label">
                        <
left>475</left>
                        <
top>3</top>
                        <
width>300</width>
                        <
height>22</height>
                        <
font>font13</font>
                        <
aligny>center</aligny>
                        <
selectedcolor>green</selectedcolor>
                        <
textcolor>grey</textcolor>
                        <
align>right</align>
                        <
info>ListItem.Label2</info>
                </
control> -->
      </
focusedlayout>
</
control
[/code]

Image

Image
Reply
#6
Code:
<focusedlayout height="95" width="180">
                <control type="image">
                        <width>485</width>

perhaps because the image width exceeds the width of the focused layout?
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
#7
Thank You!
Reply
#8
Another question how would I go about using 2 list controls in the same gui. It just continues to the right.

PHP Code:
class GUI(xbmcgui.WindowXMLDialog):
    
def onInit(self):
        
request Request('https://api.trakt.tv/movies/trending?extended=full,images'headers=headers)
        
response_body urlopen(request).read()
        
info_decoded json.loads(response_body)
        
urlopen(request).close()
        for 
x in range(010):
            
cover str(info_decoded[x]['movie']['images']['poster']['full'])
            
movieName info_decoded[x]['movie']['title']
            
rating float("{0:.1f}".format(info_decoded[x]['movie']['rating']))
            
votes info_decoded[x]['movie']['votes']
            
watchers info_decoded[x]['watchers']
            
item xbmcgui.ListItem(label=movieNameiconImage=cover)
            
item.setInfo(type="Video"infoLabels={"Title"movieName"Rating"rating"Votes"votes"Studio"watchers })
            
self.addItem(item)

        
request Request('https://api.trakt.tv/shows/trending?extended=full,images'headers=headers)
        
response_body urlopen(request).read()
        
info_decoded json.loads(response_body)
        
urlopen(request).close()
        for 
x in range(010):
            
showName info_decoded[x]['show']['title']
            
tv_cover info_decoded[x]['show']['images']['poster']['full']
            
item xbmcgui.ListItem(label=showNameiconImage=tv_cover)
            
self.addItem(item)

[
img]http://imageshack.com/a/img923/1218/1hJUFR.png[/img] 
Reply
#9
create two list control in your xml file, each with a unique id.

in python, define something like
Code:
list_one = self.getControl(600)
list_two = self.getControl(700)

after that, you can just use:
Code:
list_one.addItems(...)
and
Code:
list_two.addItems(...)
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
#10
oh, just in case, it might be worth reading: https://apiblog.trakt.tv/trakt-api-image....pl89hbec7
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
#11
.addItems(), not .appendItems() Smile
Donate: https://kodi.tv/contribute/donate (foundation), 146Gr48FqHM7TPB9q33HHv6uWpgQqdz1yk (BTC personal)
Estuary: Kodis new default skin - ExtendedInfo Script - KodiDevKit
Reply
#12
Thank you I received the email from trakt last night I am going to change for it to pull the cover from somewhere else.

Getting each control individualy does not work for the second list just for the first list. Also it does no give me rating and votes info on the first movie unless I click on another movie.

PHP Code:
class GUI(xbmcgui.WindowXMLDialog):
    
def onInit(self):
        
xbmc.log('Alex')
        
request Request('https://api.trakt.tv/movies/trending?extended=full,images'headers=headers)
        
response_body urlopen(request).read()
        
info_decoded json.loads(response_body)
        
urlopen(request).close()
        
list_one self.getControl(50)
        
items = []
        for 
x in range(010):
            
cover str(info_decoded[x]['movie']['images']['poster']['full'])
            
movieName info_decoded[x]['movie']['title']
            
rating float("{0:.1f}".format(info_decoded[x]['movie']['rating']))
            
votes info_decoded[x]['movie']['votes']
            
watchers info_decoded[x]['watchers']
            
item xbmcgui.ListItem(label=movieNameiconImage=cover)
            
item.setInfo(type="Video"infoLabels={"Title"movieName"Rating"rating"Votes"votes"Studio"watchers })
            
items.append(item
        
list_one.addItems(items)

        
list_two self.getControl(60)
        
request Request('https://api.trakt.tv/shows/trending?extended=full,images'headers=headers)
        
response_body urlopen(request).read()
        
info_decoded json.loads(response_body)
        
urlopen(request).close()
        
items2 = []
        for 
x in range(010):
            
showName info_decoded[x]['show']['title']
            
tv_cover info_decoded[x]['show']['images']['poster']['full']
            
item2xbmcgui.ListItem(label=showNameiconImage=tv_cover)
            
item2.setInfo(type="Video",infoLabels={"Title"'Why'})
            
items2.append(item2)
        
xbmc.log(str(items2))
        
list_two.addItems(items2
Code:
<window>
    <controls>
        <control type="image" id="">
            <description>Black Background</description>
            <posx>158</posx>
            <posy>183</posy>
            <width>965</width>
            <height>344</height>
            <texture>black.png</texture>
        </control>
        
        <control type="list" id="50">
              <description>My first list container</description>
              <left>170</left>
              <top>215</top>
              <width>1150</width>
              <height>1100</height>
              <visible>true</visible>
              <onup>2</onup>
              <ondown>3</ondown>
              <onleft>1</onleft>
              <onright>1</onright>
              <viewtype label="list">list</viewtype>
              <orientation>horizontal</orientation>
              <pagecontrol>8</pagecontrol>

              <itemlayout width="95" height="180">      
                        <control type="image">
                                <left>0</left>
                                <top>3</top>
                                <width>80</width>
                                <height>120</height>
                                <info fallback="cover.png">ListItem.Icon</info>
                        </control>
                        
                        <control type="label">
                                <left>0</left>
                                <top>123</top>
                                <width>80</width>
                                <height>22</height>
                                <font>reg16</font>
                                <aligny>left</aligny>
                                <selectedcolor>green</selectedcolor>
                                <align>left</align>
                                <info>ListItem.Title</info>
                        </control>
                        
                        <control type="image">
                                <left>0</left>
                                <top>136</top>
                                <width>12</width>
                                <height>12</height>                
                                <texture>10.png</texture>
                        </control>
                        
                        <control type="label">
                                <left>14</left>
                                <top>136</top>
                                <width>80</width>
                                <height>22</height>
                                <font>reg12</font>
                                <aligny>left</aligny>
                                <selectedcolor>green</selectedcolor>
                                <align>left</align>
                                <info>ListItem.Rating</info>
                        </control>
                        
                        <control type="label">
                                <left>27</left>
                                <top>136</top>
                                <width>80</width>
                                <height>22</height>
                                <font>reg12</font>
                                <aligny>left</aligny>
                                <selectedcolor>green</selectedcolor>
                                <align>left</align>
                                <info>ListItem.votes</info>
                        </control>
                        
                        <control type="image">
                                <left>54</left>
                                <top>136</top>
                                <width>12</width>
                                <height>12</height>                
                                <texture>eye.png</texture>
                        </control>
                        
                        <control type="label">
                                <left>69</left>
                                <top>136</top>
                                <width>80</width>
                                <height>22</height>
                                <font>reg12</font>
                                <aligny>left</aligny>
                                <selectedcolor>green</selectedcolor>
                                <align>left</align>
                                <info>ListItem.Studio</info>
                        </control>
                        
              </itemlayout>
             <!--  <focusedlayout height="180" width="95">

                        <control type="image">
                                <left>0</left>
                                <top>3</top>
                                <width>80</width>
                                <height>120</height>
                                <info>ListItem.Icon</info>
                        </control>
                        
                        <control type="label">
                                <left>0</left>
                                <top>123</top>
                                <width>80</width>
                                <height>22</height>
                                <font>reg16</font>
                                <aligny>left</aligny>
                                <selectedcolor>green</selectedcolor>
                                <align>left</align>
                                <info>ListItem.Title</info>
                        </control>

              </focusedlayout> -->
        </control>
        
        <!--TV SHows -->
        <control type="list" id="60">
              <description>My second list container</description>
              <left>80</left>
              <top>250</top>
              <width>1150</width>
              <height>1100</height>
              <visible>true</visible>
              <onup>2</onup>
              <ondown>3</ondown>
              <onleft>1</onleft>
              <onright>1</onright>
              <viewtype label="list">list</viewtype>
              <orientation>horizontal</orientation>
              <pagecontrol>8</pagecontrol>
              <!-- <autoscroll>true</autoscroll>
              <scrolltime tween="sine" easing="out">200</scrolltime> -->
              <itemlayout width="95" height="180">      
                        <control type="image">
                                <left>0</left>
                                <top>3</top>
                                <width>80</width>
                                <height>120</height>
                                <info fallback="cover.png">ListItem.Icon</info>
                        </control>
                        
                        <control type="label">
                                <left>0</left>
                                <top>123</top>
                                <width>80</width>
                                <height>22</height>
                                <font>reg16</font>
                                <aligny>left</aligny>
                                <selectedcolor>green</selectedcolor>
                                <align>left</align>
                                <info>ListItem.Title</info>
                        </control>                                        
                        
              </itemlayout>
            
        </control>
        

    </controls>
</window>

Image
Reply
#13
(2016-10-08, 21:59)phil65 Wrote: .addItems(), not .appendItems() Smile

* ronie simply rewrites all history
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
#14
.addItems need a list to work that's why I appended to items list then .addItems. If I change the ID for the tv one to the movie one it works it seems to be an issue with the second list in the xml. I am able to get the names now but not the covers.
Reply
#15
Got it it added the setArt and added the focus layout for it. Still playing on why the first movie wont show labels. Can I transfer focus between list. I want to add further fuctionitly down the line and want to be able to click it and get nore information on the movie.
Thank You for all your help.
Reply

Logout Mark Read Team Forum Stats Members Help
Sending Image List to WindowXMLDialog from Addon0