2017-07-15, 15:00
Hello all. I'm knew to Kodi development, but not to Python and am struggling with my initial attempt at building a script that calls an XML file to populate a basic control on screen.
My Python script is:
...and my XML file in the location referenced in the script is:
I am getting an error though of:
...I can't help but think I am nearly there with this and have just made a small mistake somewhere.
Can anyone assist in resolving?
My Python script is:
Code:
import xbmc, xbmcgui, os
class cGUI(xbmcgui.WindowXML):
def __init__(self, *args, **kwargs):
xbmcgui.WindowXML.__init__(self, *args, **kwargs)
self.addControl(xbmcgui.ControlImage(0, 0, 1300, 720, 'special://home//addons//script.video.test2//resources//images//Test file.jpg'))
self.listing = kwargs.get("listing")
self.main_control_id = kwargs.get("id")
def onInit(self):
self.exit_monitor = ExitMonitor(self.close_gui)
self.gui_listbox = self.getControl(self.main_control_id)
self.gui_listbox.reset()
def onClick(self, controlID):
if controlID == self.main_control_id:
self.gui_listbox_SelectedPosition = self.gui_listbox.getSelectedPosition()
def onAction(self, action):
focused_control=self.getFocusId()
if action in [ xbmcgui.ACTION_MOVE_LEFT ]:
if focused_control==self.main_control_id:
self.message('You selected : Test Item')
ui = cGUI('controltest.xml', 'special://home//script.video.test2//resources//skins//Default//1080i', default='Default', defaultRes='1080i', id=1100)
ui.doModal()
...and my XML file in the location referenced in the script is:
Code:
<control type="button" id="1100">
<description>My first button control</description>
<left>80</left>
<top>60</top>
<width>250</width>
<height>200</height>
<visible>true</visible>
<colordiffuse>FFFFFFFF</colordiffuse>
<texturefocus colordiffuse="FFFFAAFF">myfocustexture.png</texturefocus>
<texturenofocus colordiffuse="FFFFAAFF">mynormaltexture.png</texturenofocus>
<label>29</label>
<wrapmultiline>true</wrapmultiline>
<font>font12</font>
<textcolor>FFFFFFFF</textcolor>
<focusedcolor>FFFFFFFF</focusedcolor>
<disabledcolor>80FFFFFF</disabledcolor>
<invalidcolor>FFFFFFFF</invalidcolor>
<align></align>
<aligny></aligny>
<textoffsetx></textoffsetx>
<textoffsety></textoffsety>
<pulseonselect></pulseonselect>
<onclick>XBMC.ActivateWindow(MyVideos)</onclick>
<onfocus>-</onfocus>
<onunfocus>-</onunfocus>
<onup>2</onup>
<ondown>3</ondown>
<onleft>1</onleft>
<onright>1</onright>
</control>
I am getting an error though of:
Code:
RuntimeError: XML File for Window is missing
...I can't help but think I am nearly there with this and have just made a small mistake somewhere.
Can anyone assist in resolving?