Kodi Community Forum

Full Version: Help with WindowXMLDialog DialogSelect derived class
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
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:

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 
indexitem in enumerate(self.listing):
            
name_str item['name']
            
URL_str  item['disp_URL']
            
listitem xbmcgui.ListItem(label name_strlabel2 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!
hmm.. i think accessing DialogSelect.xml in this way (and the way i do in resource select) is not entirely fail-safe.
tbh, i'm not sure if there's a way around these issues. at lease not from the addon side.
it may require changes in the skin i think.

i'll dig a bit deeper as soon as i find some time.
(2016-09-27, 13:01)ronie Wrote: [ -> ]hmm.. i think accessing DialogSelect.xml in this way (and the way i do in resource select) is not entirely fail-safe.
tbh, i'm not sure if there's a way around these issues. at lease not from the addon side.
it may require changes in the skin i think.

i'll dig a bit deeper as soon as i find some time.

Thanks ronie. It would be nice if this can be solved because a select dialog that displays icons would be fundamental for Advanced Emulator Launcher.

More testing: I now use self.button_cancel.setVisible(False). This seems to work OK in Estuary. However, if using Confluence in Krypton, if you move from the ListItem to the ScrollBar no matter what key is pressed you cannot return to the ListItem! Is it a Confluence skin bug?
nah, neither are skin bugs.

the problem is using the DialogSelect.xml file in a way that isn't really supported.
when kodi uses the select dialog it handles the visiblility of either control 3 or 6
and makes sure the right one gets focused. and also takes care of proper navigation to the list.

i don't think there's a way to properly handle this in your (or any) addon.


the right way to proceed would be to extend the functionality of the xbmcgui.Dialog().select() method,
which is basically what addons should be using instead.
i think two things are needed here:
- allow addons to pass listitems to this method instead of just labels.
- add a bool (useDetails) to be able to select either control 3 or 6 to be visible.

should be easy, right? ;-)
To fix navigation via skin work it should be possible to put both lists into a group control and focus that group instead of a specific list. ( --> edit onleft of scrollbar)

A better solution would be what ronie suggested though, but that needs a very bit of C++ skills.
...in estuary i use this, that might also work:

<onleft condition="Control.IsVisible(3)">3</onleft>
<onleft condition="Control.IsVisible(6)">6</onleft>
Gave it a quick shot, almost finished...
https://github.com/phil65/xbmc/commits/p...lectdialog
(2016-09-28, 02:04)phil65 Wrote: [ -> ]Gave it a quick shot, almost finished...
https://github.com/phil65/xbmc/commits/p...lectdialog
Just wanted to say thanks for looking into this!
@ronie @phil65

Thank you so much for fixing this! As I said, this is going to be a killer feature for AEL when editing/scraping ROM assets. Probably many other addons will benefit as well.

Please notify me in this thread when this patch reaches the nightly builds and will test ASAP. I will need to change quite a few lines of code in AEL (and definitely code is going to luck much more cleaner) and that will make AEL only suitable for Krypton and up... but that's the future Smile

Also, do you think this patch will reach Krypton stable on time?
nope, it will be for kodi v18. Krypton is in feature-freeze.
(2016-09-28, 17:13)phil65 Wrote: [ -> ]nope, it will be for kodi v18. Krypton is in feature-freeze.

OK Phil65, thanks. Please notify in this thread when the change is merged into master to start doing the modifications in AEL.
(2016-09-28, 18:25)Wintermute0110 Wrote: [ -> ]OK Phil65, thanks. Please notify in this thread when the change is merged into master to start doing the modifications in AEL.

you can check the progress out yourself now. Wink
https://github.com/xbmc/xbmc/pull/10586
(2016-09-29, 06:14)phil65 Wrote: [ -> ]
(2016-09-28, 18:25)Wintermute0110 Wrote: [ -> ]OK Phil65, thanks. Please notify in this thread when the change is merged into master to start doing the modifications in AEL.

you can check the progress out yourself now. Wink
https://github.com/xbmc/xbmc/pull/10586

Thanks a lot Phil.

In Krypton AEL will behave fine with Estuary. Maybe I will talk with Jezz_X to patch Confluence (I am myself still very attached to Confluence even in Krypton, hehe) and I will tell to skinners making views for AEL about this problem. I will mark this as a known issue that will be fixed in v18.

When v18 reaches alpha then I will update AEL Python's code. Those changes will make AEL incompatible with previous Kodi versions but users will have plenty of time to do the transition.
(2016-09-29, 09:09)Wintermute0110 Wrote: [ -> ]In Krypton AEL will behave fine with Estuary. Maybe I will talk with Jezz_X to patch Confluence (I am myself still very attached to Confluence even in Krypton, hehe) and I will tell to skinners making views for AEL about this problem. I will mark this as a known issue that will be fixed in v18.
I already forwarded the navigation issue to Hitcher who is maintaining Confluence atm, it should be fixed with next Confluence update.
(2016-09-29, 09:09)Wintermute0110 Wrote: [ -> ]When v18 reaches alpha then I will update AEL Python's code. Those changes will make AEL incompatible with previous Kodi versions but users will have plenty of time to do the transition.
We have different repositories for different Kodi versions. That means that you can deliver the "new" version to v18 users while users of lower kodi builds still get the "old" compatible version.
(2016-09-28, 18:25)Wintermute0110 Wrote: [ -> ]Please notify in this thread when the change is merged into master to start doing the modifications in AEL.

here's your notification ;-)
Pages: 1 2