Kodi Development 22.0
for Binary and Script based Add-Ons
 
Loading...
Searching...
No Matches

Detailed Description

Code based skin access.

Offers classes and functions that manipulate the add-on gui controls.


Class: Control()

Code based skin access.

Kodi is noted as having a very flexible and robust framework for its GUI, making theme-skinning and personal customization very accessible. Users can create their own skin (or modify an existing skin) and share it with others.

Kodi includes a new GUI library written from scratch. This library allows you to skin/change everything you see in Kodi, from the images, the sizes and positions of all controls, colours, fonts, and text, through to altering navigation and even adding new functionality. The skin system is quite complex, and this portion of the manual is dedicated to providing in depth information on how it all works, along with tips to make the experience a little more pleasant.


Topics

 Subclass - ControlSpin
 Used for cycling up/down controls.
 
 Subclass - ControlLabel
 Used to show some lines of text.
 
 Subclass - ControlEdit
 
 Subclass - ControlList
 Used for a scrolling lists of items. Replaces the list control.
 
 Subclass - ControlFadeLabel
 Used to show multiple pieces of text in the same position, by fading from one to the other.
 
 Subclass - ControlTextBox
 Used to show a multi-page piece of text.
 
 Subclass - ControlImage
 Used to show an image.
 
 Subclass - ControlProgress
 Used to show the progress of a particular operation.
 
 Subclass - ControlButton
 A standard push button control.
 
 Subclass - ControlGroup
 Used to group controls together..
 
 Subclass - ControlRadioButton
 A radio button control (as used for on/off settings).
 
 Subclass - ControlSlider
 Used for a volume slider.
 

Function Documentation

◆ getId()

getId ( )

Function: getId()


Returns the control's current id as an integer.

Returns
int - Current id

Example:

...
id = self.button.getId()
...

◆ getX()

getX ( )

Function: getX()


Returns the control's current X position.

Returns
int - Current X position

Example:

...
posX = self.button.getX()
...

◆ getY()

getY ( )

Function: getY()


Returns the control's current Y position.

Returns
int - Current Y position

Example:

...
posY = self.button.getY()
...

◆ getHeight()

getHeight ( )

Function: getHeight()


Returns the control's current height as an integer.

Returns
int - Current height

Example:

...
height = self.button.getHeight()
...

◆ getWidth()

getWidth ( )

Function: getWidth()


Returns the control's current width as an integer.

Returns
int - Current width

Example:

...
width = self.button.getWidth()
...

◆ setEnabled()

setEnabled ( ...)

Function: setEnabled(enabled)


Sets the control's enabled/disabled state.

Parameters
enabledbool - True=enabled / False=disabled.

Example:

...
self.button.setEnabled(False)
...

◆ setVisible()

setVisible ( ...)

Function: setVisible(visible)


Sets the control's visible/hidden state.

Parameters
visiblebool - True=visible / False=hidden.

v19 Python API changes
You can now define the visible state of a control before it being added to a window. This value will be taken into account when the control is later added.

Example:

...
self.button.setVisible(False)
...

◆ isVisible()

isVisible ( ...)

Function: isVisible()


Get the control's visible/hidden state with respect to the container/window

Note
If a given control is set visible (c.f. setVisible() but was not yet added to a window, this method will return False (the control is not visible yet since it was not added to the window).

v18 Python API changes
New function added.

Example:

...
if self.button.isVisible():
...

◆ setVisibleCondition()

setVisibleCondition ( ...)

Function: setVisibleCondition(visible[,allowHiddenFocus])


Sets the control's visible condition.

Allows Kodi to control the visible status of the control.

List of Conditions

Parameters
visiblestring - Visible condition
allowHiddenFocus[opt] bool - True=gains focus even if hidden

Example:

...
# setVisibleCondition(visible[,allowHiddenFocus])
self.button.setVisibleCondition('[Control.IsVisible(41) + !Control.IsVisible(12)]', True)
...

◆ setEnableCondition()

setEnableCondition ( ...)

Function: setEnableCondition(enable)


Sets the control's enabled condition.

Allows Kodi to control the enabled status of the control.

List of Conditions

Parameters
enablestring - Enable condition.

Example:

...
# setEnableCondition(enable)
self.button.setEnableCondition('System.InternetState')
...

◆ setAnimations()

setAnimations ( ...)

Function: setAnimations([(event, attr,)*])


Sets the control's animations.

[(event,attr,)*]: list - A list of tuples consisting of event and attributes pairs.

Animating your skin

Parameters
eventstring - The event to animate.
attrstring - The whole attribute string separated by spaces.

Example:

...
# setAnimations([(event, attr,)*])
self.button.setAnimations([('focus', 'effect=zoom end=90,247,220,56 time=0',)])
...

◆ setPosition()

setPosition ( ...)

Function: setPosition(x, y)


Sets the controls position.

Parameters
xinteger - x coordinate of control.
yinteger - y coordinate of control.
Note
You may use negative integers. (e.g sliding a control into view)

Example:

...
self.button.setPosition(100, 250)
...

◆ setWidth()

setWidth ( ...)

Function: setWidth(width)


Sets the controls width.

Parameters
widthinteger - width of control.

Example:

...
self.image.setWidth(100)
...

◆ setHeight()

setHeight ( ...)

Function: setHeight(height)


Sets the controls height.

Parameters
heightinteger - height of control.

Example:

...
self.image.setHeight(100)
...

◆ setNavigation()

setNavigation ( ...)

Function: setNavigation(up, down, left, right)


Sets the controls navigation.

Parameters
upcontrol object - control to navigate to on up.
downcontrol object - control to navigate to on down.
leftcontrol object - control to navigate to on left.
rightcontrol object - control to navigate to on right.
Exceptions
TypeErrorif one of the supplied arguments is not a control type.
ReferenceErrorif one of the controls is not added to a window.
Note
Same as controlUp(), controlDown(), controlLeft(), controlRight(). Set to self to disable navigation for that direction.

Example:

...
self.button.setNavigation(self.button1, self.button2, self.button3, self.button4)
...

◆ controlUp()

controlUp ( ...)

Function: controlUp(control)


Sets the controls up navigation.

Parameters
controlcontrol object - control to navigate to on up.
Exceptions
TypeErrorif one of the supplied arguments is not a control type.
ReferenceErrorif one of the controls is not added to a window.
Note
You can also use setNavigation(). Set to self to disable navigation.

Example:

...
self.button.controlUp(self.button1)
...

◆ controlDown()

controlDown ( ...)

Function: controlDown(control)


Sets the controls down navigation.

Parameters
controlcontrol object - control to navigate to on down.
Exceptions
TypeErrorif one of the supplied arguments is not a control type.
ReferenceErrorif one of the controls is not added to a window.
Note
You can also use setNavigation(). Set to self to disable navigation.

Example:

...
self.button.controlDown(self.button1)
...

◆ controlLeft()

controlLeft ( ...)

Function: controlLeft(control)


Sets the controls left navigation.

Parameters
controlcontrol object - control to navigate to on left.
Exceptions
TypeErrorif one of the supplied arguments is not a control type.
ReferenceErrorif one of the controls is not added to a window.
Note
You can also use setNavigation(). Set to self to disable navigation.

Example:

...
self.button.controlLeft(self.button1)
...

◆ controlRight()

controlRight ( ...)

Function: controlRight(control)


Sets the controls right navigation.

Parameters
controlcontrol object - control to navigate to on right.
Exceptions
TypeErrorif one of the supplied arguments is not a control type.
ReferenceErrorif one of the controls is not added to a window.
Note
You can also use setNavigation(). Set to self to disable navigation.

Example:

...
self.button.controlRight(self.button1)
...