Kodi Community Forum

Full Version: python add-on for GUI - how to use different custom XMLs for different views
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi , I'm working on creating a Video add-on by using  "plugin.video.example" as the starting point. In this I basically want custom look for the views and so I created a Custom XML file that I use for GUI when the plugin loads.

In this Custom XML file I have created multiple panels each with a different look. Depending on the view/look I want, I hide all but one Panel and then I populate that panel in Python script. This has been working alright for me.

But now I need to create additional Views/Looks and the one XML file I have been using is becoming quite large. So I am wondering if there is a way for me to load a different XML for each View/Look  and populate it from Python add-on.

Here is how I have created the add-on and am using the Custom XML.

Python Script has the following sections:

In __main__

ui = GUI('Custom_Kodi_Interface.xml', CWD, 'default', '720p', querystring=sys.argv[2][1:])
ui.doModal()
del ui


# in this class we initialize all the controls and handle the onClick and onAction events
class GUI(xbmcgui.WindowXML):

In Custom_Kodi_Interface.xml I've assigned it a window id of 1139 and then created multiple panels inside it. Each panel is assigned a unique ID and has different controls - icons/labels etc.

<control type="panel" id="100">... </control>
<control type="panel" id="120">... </control>
<control type="panel" id="200">... </control>
<control type="panel" id="300">... </control>


I can load another Custom_XML with window id '1140'.  In python I call to load this XML via xbmc.executebuiltin('ActivateWindow(1140)') . The XML loads fine, but it does not get populated. I have a List that I'd like to populate in this XML.

kodi.log has no errors. The problem as I see it is, that python script is tied to the first XML that was loaded and is only aware of the control ID's in that XML. So when I fetch a control using ID and try to populate it then it will not populate the controls in the new XML even if the control ID is the same number.

Please advice if what I am trying to do is possible or not ? If not, what is my best option on creating separate XML files for separate Views/looks and load them as and when needed.
window id's for python windows are assigned dynamically by kodi. it's not possible to assign a window id yourself.

also, it's not possible to have multiple xml files for several views. you need to place the code for all views in the same xml file.
Thanks Ronie. Appreciate your response.

I'll make do with one XML file then.