addon: highlight list items and other gui animations
#1
How would i go about adding animations to lists? Is there any python functions or actions i could use or do i have to use windowsxml(i have no idea how to do this). I am not concerned about making sure my script is astheticly pleasing and will only be using the default confluence skin. It seems like this should be fairly simple to atleast be able to add some simple animation to atleast show which item in list is currently selected but after looking through the available functions i cant seem to find anything.
Code:
import xbmc, xbmcgui

#get actioncodes from https://github.com/xbmc/xbmc/blob/master/xbmc/guilib/Key.h
ACTION_PREVIOUS_MENU = 10

class MyClass(xbmcgui.Window):
  def __init__(self):
    self.strActionInfo = xbmcgui.ControlLabel(250, 80, 200, 200, '', 'font14', '0xFFBBBBFF')
    self.addControl(self.strActionInfo)
    self.strActionInfo.setLabel('Push BACK to quit')
    self.list = xbmcgui.ControlList(200, 150, 300, 400)
    self.addControl(self.list)
    self.list.addItem('Item 1')
    self.list.addItem('Item 2')
    self.list.addItem('Item 3')
    self.setFocus(self.list)

  def onAction(self, action):
    if action == ACTION_PREVIOUS_MENU:
      self.close()

  def onControl(self, control):
    if control == self.list:
      item = self.list.getSelectedItem()
      self.message('You selected : ' + item.getLabel())  

  def message(self, message):
    dialog = xbmcgui.Dialog()
    dialog.ok(" My message title", message)

mydisplay = MyClass()
mydisplay.doModal()
del mydisplay
Reply
#2
Like selected item color ect?
http://xbmc.sourceforge.net/python-docs/...ontrolList
Or animation?
http://xbmc.sourceforge.net/python-docs/...Animations
Image [RELEASE] Metroid
Image [RELEASE] IrcChat
Reply
#3
thanks that is helpful but i have tried using the following but i still cant seem to highlight the currently selected item in list. Perhaps i need to add action for each time an element is selected?
Code:
self.list = xbmcgui.ControlList(200, 150, 300, 400, textColor = '0xFFDEDEDF', selectedColor = '0xFF39DE5A')
I could just use a list of buttons since when they are initialized they already have some simple highlighting animations but then i run into a problem when trying to add or remove buttons from window(addControl(), removeControl) i keep getting runtime errors. I know its probably because i am trying to add button to control that is already added to window and vice versa when removing button from window but i still cant seem to solve this problem.
Code:
def updatePage(self):
    start_index = ((currPage-1) * (self.getHeight()-200)/50)
    end_index = (currPage * (self.getHeight()-200)/50)
    if (currPage * (self.getHeight()-200)/50) > len(buttonList):
        end_index = len(buttonList)
    else:
        end_index = (currPage * (self.getHeight()-200)/50)
    for i in range(len(buttonList)):
        if (i >= start_index) or i+start_index < end_index:
           if not self.activeButtons[i]:
               self.addControl(self.buttonList[i])
                self.buttonList[i] = True
           else:
               self.removeControl(self.buttonList[i])
               self.buttonList[i] = False
Reply
#4
it is better to define the window and the base control as an xml file.
window logic and adding of content or listitems can be done in python
no all features of the gui are reachable with python -> http://wiki.xbmc.org/index.php?title=List_Container

for specific lists in xml you have the sections <itemlayout and <focusedlayout

for an working example look here: http://forum.xbmc.org/showthread.php?tid=164067
Reply

Logout Mark Read Team Forum Stats Members Help
addon: highlight list items and other gui animations0