need info regarding controllist in xbmcgui
#1
Hi,

This code come from a game made in kodi it is a puzzle game.

I have understand this code that makes a vertical list of words in a controllist made in xbmcgui:
PHP Code:
        l=1100-10t=30w=180h=self.scr['H']-t-35
        
self.HoroTxtBG=xbmcgui.ControlImage(l,t,w,h,self.b1,aspectRatio=0); 
        
self.HoroTxtBG2=xbmcgui.ControlImage(l,t,w,h,nofocus,aspectRatio=0); 
        
#self.HoroTxt=xbmcgui.ControlTextBox(l+10,t+2,w-20,h-4,font='font12',textColor="0xFF000000"); 
        
self.HoroTxt=xbmcgui.ControlList(l+5,t+20,w-10,h-40,font='font12',textColor="0xFF000000",selectedColor="0xFF000000",buttonFocusTexture=focus,buttonTexture=nofocus); 
        
self.HoroTxt.setSpace(2); 
        
self.HoroTxt.setImageDimensions(0,0); 
        
#,itemTextXOffset=-30,itemTextYOffset=-5
        
self.HoroTxt.setItemHeight(14); 
        
zz=[self.HoroTxtBG,self.HoroTxtBG2,self.HoroTxt]
        
        for 
z in zz:
            
self.addControl(z); #z.setAnimations([('WindowOpen','effect=fade delay=2000 time=2000 start=0 end=80')]);
        
        
self.HoroTxtBG.setWidth(w); self.HoroTxtBG.setHeight(h); self.HoroTxtBG2.setWidth(w); self.HoroTxtBG2.setHeight(h); 
        
self.HoroTxtBG.setAnimations([('WindowOpen','effect=fade delay=2000 time=2000 start=0 end=70')]); 
        
self.HoroTxtBG2.setAnimations([('WindowOpen','effect=fade delay=2000 time=2000 start=0 end=98')]); 
        
self.HoroTxt.setAnimations([('WindowOpen','effect=fade delay=2000 time=2000 start=0')]); ; 
        
self.HoroTxt.addItems(self.PuzzleWordList.split('\n')); 
But i was not able to figure how to get the labels of the items that the users click on them in this list, so i can takes later actions to them

Can you guide me what to do ?

thanks

iLovePython2000
Reply
#2
Where self.PuzzleWordList is a list of labels from a text file i can replace it by this by example :

self.PuzzleWordList = ['player 1', 'player2', 'player 3', player4']

What i do not know, is how to get the labels of the values in the controllist, which the users have click on them, such as, by example, Player 3 and Player 4.

thanks for the editing btw
Reply
#3
what i try to explain is, i will like to get the labels of the items selected by a user from a xbmcgui controlList
Reply
#4
found this piece of code that is quite good:

import xbmc
import xbmcgui

#get actioncodes from keymap.xml

ACTION_MOVE_LEFT = 1
ACTION_MOVE_RIGHT = 2
ACTION_MOVE_UP = 3
ACTION_MOVE_DOWN = 4
ACTION_PAGE_UP = 5
ACTION_PAGE_DOWN = 6
ACTION_SELECT_ITEM = 7
ACTION_HIGHLIGHT_ITEM = 8
ACTION_PARENT_DIR = 9
ACTION_PREVIOUS_MENU = 10
ACTION_SHOW_INFO = 11

ACTION_PAUSE = 12
ACTION_STOP = 13
ACTION_NEXT_ITEM = 14
ACTION_PREV_ITEM = 15

class Window(xbmcgui.Window):
def __init__(self):

self.addControl(xbmcgui.ControlImage(0,0,720,576, 'background.png'))
self.list = xbmcgui.ControlList(200, 100, 400, 400)
self.strAction = xbmcgui.ControlLabel(50, 100, 100, 20, 'action', 'font13', '0xFFFF3300')
self.strButton = xbmcgui.ControlLabel(50, 150, 100, 20, 'button', 'font13', '0xFFFFFFFF')

self.addControl(self.list)
self.addControl(self.strAction)
self.addControl(self.strButton)

self.button1 = xbmcgui.ControlButton(50, 200, 90, 30, "Button 1")
self.button2 = xbmcgui.ControlButton(50, 240, 90, 30, "Button 2")
self.addControl(self.button1)
self.addControl(self.button2)

self.button1.controlDown(self.button2)
self.button1.controlRight(self.list)
self.button2.controlUp(self.button1)
self.button2.controlRight(self.list)
self.list.controlLeft(self.button1)

# add a few items to the list
xbmcgui.lock()
for i in range(50):
self.list.addItem('item' + str(i))
xbmcgui.unlock()
self.setFocus(self.button1)

def onAction(self, action):
if action == ACTION_PREVIOUS_MENU:
print('action recieved: previous')
self.close()
if action == ACTION_SHOW_INFO:
self.strAction.setLabel('action recieved: show info')
if action == ACTION_STOP:
self.strAction.setLabel('action recieved: stop')
if action == ACTION_PAUSE:
print('pause')
dialog = xbmcgui.Dialog()
dialog.ok('action recieved','ACTION_PAUSE')

def onControl(self, control):
if control == self.button1:
self.strButton.setLabel('button 1 clicked')
elif control == self.button2:
self.strButton.setLabel('button 2 clicked')
elif control == self.list:
item = self.list.getSelectedItem()
self.strButton.setLabel('selected : ' + self.list.getSelectedItem().getLabel())
item.setLabel(item.getLabel() + '1')

w = Window()
w.doModal()

del w
Reply

Logout Mark Read Team Forum Stats Members Help
need info regarding controllist in xbmcgui0