2016-09-27, 12:36
In Advanced Emulator Launcher I use a WindowXMLDialog derived class to present a user a select window that displays thumbs for each item. I got the idea from Advanced Launcher and from Ronie's script.image.resource.select. I use the following code:
Which produces this nice result
However, there are some problems I cannot solve without an expert:
1) With the current implementation if key --> is pressed then focus goes from the List to the Scrollbar to the Cancel button to the List again. This is OK.
2) However, if the Cancel button is focused and <-- is pressed, then there is no action. I have tried to use self.button_cancel.controlLeft(self.scrollbar) but then when I try to get the control object for the scrollbar I get an exception: RuntimeError: Unknown control type for python
3) Whenever the select dialog is created I get in the Kodi log: ERROR: Control 3 in window 13000 has been asked to focus, but it can't. How can I avoid this?
Can you please someone help me to fix the navigation of this dialog? Thanks a lot!
PHP Code:
def onInit(self):
# --- This control is a listitem that only displays text and label_1 ---
# >> It is not used, make it invisible
self.getControl(3).setVisible(False)
# --- Container that displays icon, label_1 and label_2 for each listview item ---
self.container = self.getControl(6)
# --- Scrollbar ---
# >> In Krypton produces and exception RuntimeError: Unknown control type for python
# self.scrollbar = self.getControl(61)
# --- OK button ---
self.button_OK = self.getControl(5)
self.button_OK.setVisible(False)
# self.button_OK.setLabel('OK')
# >> Set navigation rules
# self.button_OK.controlLeft(self.scrollbar)
# self.button_OK.controlRight(self.container)
# >> Disables movement left-right in image listbox
# self.container.controlLeft(self.container)
# self.container.controlRight(self.container)
# >> The mysterious control 7 is new in Kodi Krypton!
# >> See http://forum.kodi.tv/showthread.php?tid=250936&pid=2246458#pid2246458
try:
# Produces an error "RuntimeError: Non-Existent Control 7"
self.button_cancel = self.getControl(7)
self.button_cancel.setLabel('Cancel')
# self.button_cancel.controlLeft(self.scrollbar)
self.button_cancel.controlRight(self.container)
except:
pass
# >> Window title on top
self.getControl(1).setLabel(self.window_title)
# >> Add items to list
listitems = []
for index, item in enumerate(self.listing):
name_str = item['name']
URL_str = item['disp_URL']
listitem = xbmcgui.ListItem(label = name_str, label2 = URL_str)
listitem.setArt({'icon' : 'DefaultAddonImages.png', 'thumb' : URL_str})
listitems.append(listitem)
self.container.addItems(listitems)
# >> Set the focus on the ListItem
self.setFocus(self.container)
Which produces this nice result
watch gallery
However, there are some problems I cannot solve without an expert:
1) With the current implementation if key --> is pressed then focus goes from the List to the Scrollbar to the Cancel button to the List again. This is OK.
2) However, if the Cancel button is focused and <-- is pressed, then there is no action. I have tried to use self.button_cancel.controlLeft(self.scrollbar) but then when I try to get the control object for the scrollbar I get an exception: RuntimeError: Unknown control type for python
3) Whenever the select dialog is created I get in the Kodi log: ERROR: Control 3 in window 13000 has been asked to focus, but it can't. How can I avoid this?
Can you please someone help me to fix the navigation of this dialog? Thanks a lot!