2006-02-04, 17:32
hi everybody !
maybe i'm not the first to find this trick, it is not the question, but i found a way to synchronise 2 lists... (or more)
you 'browse' items of one of the list, and the other one move in the same time. that way, item number x of the 1st list is always in front of item number x of 2nd list !!
this can be very helpfull for drawing arrays on xbmc screen...
it is very simple to do, anyway, mismatch can happen when using pad triggers to move fast inside the list...
have a look in it and just tell me. this example shows in a 1st list the sum of 2 numbers and in a second list the result for each sum...
here is a link : http://xbmc-scripts.gx-mod.com/documents...o_lists.py
and here is the code (not sure it will look correctly indented here) :
maybe i'm not the first to find this trick, it is not the question, but i found a way to synchronise 2 lists... (or more)
you 'browse' items of one of the list, and the other one move in the same time. that way, item number x of the 1st list is always in front of item number x of 2nd list !!
this can be very helpfull for drawing arrays on xbmc screen...
it is very simple to do, anyway, mismatch can happen when using pad triggers to move fast inside the list...
have a look in it and just tell me. this example shows in a 1st list the sum of 2 numbers and in a second list the result for each sum...
here is a link : http://xbmc-scripts.gx-mod.com/documents...o_lists.py
and here is the code (not sure it will look correctly indented here) :
Quote:#this simple script example will show you how to
# 'synchronize' several lists together
#it can be very interesting to draw some boards on your xbmc
# or to align some datas together in a kind of multitab list
#sorry for my explanations as they may appear not very understandable
# but hey ! i'm french;)
#
# alexsolex[a]gmail.com
import xbmc, xbmcgui
class main(xbmcgui.window):
def (self):
self.setcoordinateresolution(6)
#background
self.addcontrol(xbmcgui.controlimage(0,0,720,576, 'background.png'))
#1st list
self.list_1=xbmcgui.controllist(200,110,200,430,'font13','0xffffffff')
self.addcontrol(self.list_1)
self.list_1.setpagecontrolvisible(false)
#s2nd list
self.list_2=xbmcgui.controllist(300,110,200,430,'font13','0xffffffff')
self.addcontrol(self.list_2)
self.list_2.setpagecontrolvisible(false)
#fill 1st list with datas
for number in range(60):
self.list_1.additem('%s + %s = '%(number,number))
#fill 2nd list with datas
for number in range(60):
self.list_2.additem(str(number+number))
#note that you have to be sure both lists have the same length !!
self.setfocus(self.list_1)
def oncontrol(self,control):
#do your oncontrol as you need to...
#for example :
if control==self.list_1:
print "a list_1 item has been selected"
elif control == self.list_2:
print "a list_2 item has been selected"
def onaction(self, action):
#here we will check every pad inputs to move both lists together as one
#first catch control list item selected :
item = self.list_1.getselectedposition()
#then focus the same item in the second list :
self.list_2.selectitem(item)
#finally do your oncontrol as you need
#for example :
if action == action_back:
self.close()
m = main()
m.domodal()
del m