Kodi Documentation  20.0 Kodi is an open source media player and entertainment hub.
Window

GUI window class for Add-Ons. More...

Collaboration diagram for Window:

## Modules

Callback functions from Kodi to add-on
GUI window callback functions.

Subclass - WindowDialog
GUI window dialog class for Add-Ons.

Subclass - WindowXML
GUI xml window class.

## Functions

#### Function: show()

Show this window. More...

#### Function: setFocus(Control)

Give the supplied control focus. More...

#### Function: setFocusId(ControlId)

Gives the control with the supplied focus. More...

#### Function: getFocus(Control)

Returns the control which is focused. More...

#### Function: getFocusId(int)

Returns the id of the control which is focused. More...

#### Function: removeControl(Control)

Removes the control from this window. More...

#### Function: removeControls(List)

Removes a list of controls from this window. More...

#### Function: getHeight()

Returns the height of this Window instance. More...

#### Function: getWidth()

Returns the width of this Window instance. More...

#### Function: setProperty(key, value)

Sets a window property, similar to an infolabel. More...

#### Function: getProperty(key)

Returns a window property as a string, similar to an infolabel. More...

#### Function: clearProperty(key)

Clears the specific window property. More...

#### Function: clearProperties()

Clears all window properties. More...

#### Function: close()

Closes this window. More...

#### Function: doModal()

Display this window until close() is called. More...

#### Function: addControl(Control)

Add a Control to this window. More...

#### Function: addControls(List)

Add a list of Controls to this window. More...

#### Function: getControl(controlId)

Gets the control from this window. More...

## Detailed Description

This class allows over their functions to create and edit windows that can be accessed from an Add-On.

Likewise, all functions from here as well in the other window classes WindowDialog, WindowXML and WindowXMLDialog with inserted and available.

## Constructor for window

#### Class: xbmcgui.Window([existingWindowId]):

Creates a new from Add-On usable window class. This is to create window for related controls by system calls.

Parameters
 existingWindowId [opt] Specify an id to use an existing window.
Exceptions
 ValueError if supplied window Id does not exist. Exception if more then 200 windows are created.

Deleting this window will activate the old window that was active and resets (not delete) all controls that are associated with this window.

Example:

..
win = xbmcgui.Window()
width = win.getWidth()
..

## Function Documentation

#### Function: addControl(Control)

Add a Control to this window.

Parameters
Exceptions
 TypeError If supplied argument is not a Control type ReferenceError If control is already used in another window RuntimeError Should not happen :-)

The next controls can be added to a window atm

Control-class Description
ControlLabel Label control to show text
ControlTextBox To show bigger text field
ControlButton Brings a button to do some actions
ControlEdit The edit control allows a user to input text in Kodi
ControlFadeLabel The fade label control is used for displaying multiple pieces of text in the same space in Kodi
ControlList Add a list for something like files
ControlGroup Is for a group which brings the others together
ControlImage Controls a image on skin
ControlProgress Progress bar for a performed work or something else
ControlSlider The slider control is used for things where a sliding bar best represents the operation at hand
ControlSpin The spin control is used for when a list of options can be chosen
ControlTextBox The text box is used for showing a large multipage piece of text in Kodi

#### Function: addControls(List)

Add a list of Controls to this window.

Parameters
 List List with controls to add
Exceptions
 TypeError If supplied argument is not of List type, or a control is not of Control type ReferenceError If control is already used in another window RuntimeError Should not happen :-)

## ◆ clearProperties()

#### Function: clearProperties()

Clears all window properties.

Example:

..
win = xbmcgui.Window(xbmcgui.getCurrentWindowId())
win.clearProperties()
..

## ◆ clearProperty()

#### Function: clearProperty(key)

Clears the specific window property.

Parameters
 key string - property name.
Note
Key is NOT case sensitive. Equivalent to setProperty(key,'') You can use the above as keywords for arguments and skip certain optional arguments. Once you use a keyword, all following arguments require the keyword.

Example:

..
win = xbmcgui.Window(xbmcgui.getCurrentWindowId())
win.clearProperty('Category')
..

## ◆ close()

#### Function: close()

Closes this window.

Closes this window by activating the old window.

Note
The window is not deleted with this method.

## ◆ doModal()

#### Function: doModal()

Display this window until close() is called.

Todo:
garbear added this code to the python window.cpp class and commented in XBPyThread.cpp. I'm not sure how to handle this in this native implementation.

## ◆ getControl()

 Control * XBMCAddon::xbmcgui::Window::getControl ( ... )

#### Function: getControl(controlId)

Gets the control from this window.

Parameters
 controlId Control id to get
Exceptions
 Exception If Control doesn't exist
Remarks
controlId doesn't have to be a python control, it can be a control id from a Kodi window too (you can find id's in the xml files.
Note
Not python controls are not completely usable yet You can only use the Control functions

## ◆ getFocus()

#### Function: getFocus(Control)

Returns the control which is focused.

Returns
Focused control class
Exceptions
 SystemError On Internal error RuntimeError If no control has focus

## ◆ getFocusId()

#### Function: getFocusId(int)

Returns the id of the control which is focused.

Returns
Focused control id
Exceptions
 SystemError On Internal error RuntimeError If no control has focus

## ◆ getHeight()

#### Function: getHeight()

Returns the height of this Window instance.

Returns
Window height in pixels
v18 Python API changes:
Function changed

## ◆ getProperty()

#### Function: getProperty(key)

Returns a window property as a string, similar to an infolabel.

Parameters
 key string - property name.
Note
Key is NOT case sensitive.
You can use the above as keywords for arguments and skip certain optional arguments. Once you use a keyword, all following arguments require the keyword.

Example:

..
win = xbmcgui.Window(xbmcgui.getCurrentWindowId())
category = win.getProperty('Category')
..

## ◆ getWidth()

#### Function: getWidth()

Returns the width of this Window instance.

Returns
Window width in pixels
v18 Python API changes:
Function changed

## ◆ removeControl()

#### Function: removeControl(Control)

Removes the control from this window.

Parameters
 Control Control class to remove
Exceptions
 TypeError If supplied argument is not a Control type RuntimeError If control is not added to this window

This will not delete the control. It is only removed from the window.

## ◆ removeControls()

#### Function: removeControls(List)

Removes a list of controls from this window.

Parameters
 List List with controls to remove
Exceptions
 TypeError If supplied argument is not a Control type RuntimeError If control is not added to this window

This will not delete the controls. They are only removed from the window.

## ◆ setFocus()

#### Function: setFocus(Control)

Give the supplied control focus.

Parameters
 Control Control class to focus
Exceptions
 TypeError If supplied argument is not a Control type SystemError On Internal error RuntimeError If control is not added to a window

## ◆ setFocusId()

#### Function: setFocusId(ControlId)

Gives the control with the supplied focus.

Parameters
 ControlId [integer] On skin defined id of control
Exceptions
 SystemError On Internal error RuntimeError If control is not added to a window

## ◆ setProperty()

#### Function: setProperty(key, value)

Sets a window property, similar to an infolabel.

Parameters
 key string - property name. value string or unicode - value of property.
Note
Key is NOT case sensitive. Setting value to an empty string is equivalent to clearProperty(key).
You can use the above as keywords for arguments and skip certain optional arguments.
Once you use a keyword, all following arguments require the keyword.

Example:

..
win = xbmcgui.Window(xbmcgui.getCurrentWindowId())
..

## ◆ show()

#### Function: show()

Show this window.

Shows this window by activating it, calling close() after it wil activate the current window again.

Note
If your script ends this window will be closed to. To show it forever, make a loop at the end of your script or use doModal() instead.