Search code examples
pythonxmlkodi

Make this button visible without pressing with mouse in Kodi


I am trying to solve a fairly basic beginner problem with Kodi without much success. I have the start of a skinning script that opens a window and creates a control which I cant make visible by pointing my mouse over it.

However, I can't figure out how to make it so that this control button is visible without me having to move the mouse over it, immediately when the script runs. The documentation for Kodi is a bit sparse if you are a beginner with it:

...here is my default.py file...

import xbmc, xbmcgui, os

class cGUI(xbmcgui.WindowXML):

    def __init__(self, *args, **kwargs):


        xbmcgui.WindowXML.__init__(self, *args, **kwargs)

        self.strActionInfo = xbmcgui.ControlLabel(50, 50, 200, 200, '', 'font14', '0xFFBBBBFF')
        self.addControl(self.strActionInfo)
        self.strActionInfo.setLabel('Push BACK to quit')

        self.listing = kwargs.get("listing")
        self.main_control_id = kwargs.get("id")

    def onClick(self, controlID):
        if controlID == self.main_control_id:
            self.gui_button_SelectedPosition = self.gui_button.getSelectedPosition()

    def setFocusId(self, 10):

        pass

ui = cGUI('controltest.xml', 'special://home/addons/script.video.test2', id=10)
ui.doModal()
del ui

...and here is my XML file for the skin...

<?xml version="1.0" encoding="UTF-8"?>
<window type="window">
<defaultcontrol always="true">10</defaultcontrol>
  <menucontrol>9000</menucontrol>
  <backgroundcolor>1A1817</backgroundcolor>
  <views>50,51,509,510</views>
  <visible>Window.IsActive(Home)</visible>
  <animation effect="fade" time="100">WindowOpen</animation>
  <animation effect="slide" end="0,576" time="100">WindowClose</animation>
  <zorder>1</zorder>
  <coordinates>
    <left>0</left>
    <top>0</top>
    <origin x="0" y="0">Window.IsActive(Home)</origin>
  </coordinates>
  <controls>
<control type="button" id="10">
      <description>My first button control</description>
      <left>100</left>
      <top>100</top>
      <width>1100</width>
      <height>550</height>
      <visible>true</visible>
      <colordiffuse>1A1817</colordiffuse>
      <label>28</label>
      <wrapmultiline>true</wrapmultiline>
      <font>font12</font>
      <textcolor>80FFFFFF</textcolor>
      <focusedcolor>7fffffff</focusedcolor>
      <disabledcolor>80FFFFFF</disabledcolor>
    <shadowcolor>70FFFFFF</shadowcolor>
      <invalidcolor>70FFFFFF</invalidcolor>
      <align></align>
      <aligny></aligny>
      <textoffsetx></textoffsetx>
      <textoffsety></textoffsety>
      <pulseonselect></pulseonselect>
      <onfocus>-</onfocus>
      <onunfocus>-</onunfocus>
      <onup>2</onup>
      <ondown>3</ondown>
      <onleft>1</onleft>
      <onright>1</onright>
</control>
</controls>
</window>

Can anyone please let me know what I need to add/change to make this work?

Thanks


Solution

  • You should define a texturefocus and a texturenofocus for the button control.