pyxbmct.addonwindow

This module contains all the Window classes of the PyXBMCt framework

Classes

AbstractWindow() Top-level control window.
AddonDialogWindow([title]) Addon UI container with a transparent background.
AddonFullWindow([title]) Addon UI container with a solid background.
AddonWindow([title]) Top-level control window.
BlankDialogWindow() Addon UI container with a transparent background.
BlankFullWindow() Addon UI container with a solid background.
class pyxbmct.addonwindow.AbstractWindow[source]

Bases: pyxbmct.abstractgrid.AbstractGrid

Top-level control window.

The control windows serves as a parent widget for other XBMC UI controls much like Tkinter.Tk or PyQt QWidget class.

This class is a basic “skeleton” for a control window.

Warning

This is an abstract class and is not supposed to be instantiated directly!

autoNavigation(vertical_wrap_around=True, horizontal_wrap_around=True, include_disabled=False, include_invisible=False, controls_subset=None, control_types=(<class 'pyxbmct.addoncontrols.Button'>, <class 'pyxbmct.addoncontrols.List'>, <class 'pyxbmct.addoncontrols.RadioButton'>, <class 'pyxbmct.addoncontrols.Slider'>, <class 'pyxbmct.addoncontrols.Edit'>))[source]

Automatically setup the navigation between controls in the Window

Parameters:
  • vertical_wrap_around – if you navigate up from the topmost control it will take you to the bottommost control
  • horizontal_wrap_around – if you navigate down from the bottommost control it will take you to the topmost control
  • include_disabled – include controls that are disabled
  • include_invisible – include controls that are currently not visible
  • controls_subset – pass in a specific set of controls to set up the navigation for (only these controls will be effacted and then can will only be set up to navigate to each other)
  • control_types – the types of controls to consider for the navigation
setGeometry(width_, height_, rows_, columns_, pos_x=-1, pos_y=-1)[source]

Set width, height, Grid layout, and coordinates (optional) for a new control window.

Parameters:
  • width – widgh of the created window.
  • height – height of the created window.
  • rows – # rows of the Grid layout to place controls on.
  • columns – # colums of the Grid layout to place controls on.
  • pos_x – (opt) x coordinate of the top left corner of the window.
  • pos_y – (opt) y coordinates of the top left corner of the window.

If pos_x and pos_y are not privided, the window will be placed at the center of the screen.

Example:

self.setGeometry(400, 500, 5, 4)
getRows()[source]

Get grid rows count.

Raises:AddonWindowError if a grid has not yet been set.
getColumns()[source]

Get grid columns count.

Raises:AddonWindowError if a grid has not yet been set.
getX()[source]

Get X coordinate of the top-left corner of the window.

getY()[source]

Get Y coordinate of the top-left corner of the window.

getWindowWidth()[source]

Get window width.

getWindowHeight()[source]

Get window height.

connect(event, callback)[source]

Connect an event to a function.

Parameters:
  • event – event to be connected.
  • callback – callback object the event is connected to.

An event can be an instance of a Control object or an integer key action code. Several basic key action codes are provided by PyXBMCt. xbmcgui module provides more action codes.

You can connect the following Controls: Button, RadioButton and List. Other Controls do not generate any control events when activated so their connections won’t work.

To catch Slider events you need to connect the following key actions: ACTION_MOVE_LEFT, ACTION_MOVE_RIGHT and ACTION_MOUSE_DRAG, and do a check whether the Slider instance is focused.

callback parameter is a function or a method to be executed on when the event is fired.

Warning

For connection you must provide a function object without brackets (), not a function call!

lambda can be used as to call another function or method with parameters known at runtime.

Examples:

self.connect(self.exit_button, self.close)

or:

self.connect(ACTION_NAV_BACK, self.close)
connectEventList(events, callback)[source]

Connect a list of controls/action codes to a function.

See connect() docstring for more info.

disconnect(event, callback=None)[source]

Disconnect an event from a function.

An event can be an inctance of a Control object or an integer key action code which has previously been connected to a function or a method.

Parameters:
  • event – event to be disconnected.
  • callback – callback related to the event to be disconnected (if None then all callbacks are disconnected).
Raises:

AddonWindowError if an event is not connected to any function.

Examples:

self.disconnect(self.exit_button)

or:

self.disconnect(ACTION_NAV_BACK)
disconnectEventList(events, callback=None)[source]

Disconnect a list of controls/action codes from functions.

See disconnect() docstring for more info.

Parameters:
  • events – the list of events to be disconnected.
  • callback – callback related to each of the events to be disconnected (if None then all callbacks are disconnected).
Raises:

AddonWindowError if at least one event in the list is not connected to any function.

setAnimation(control)[source]

Set animation for control

Parameters:control – control for which animation is set.

This method is called automatically to set animation properties for all controls added to the current addon window instance – both for built-in controls (window background, title bar etc.) and for controls added with placeControl().

It receives a control instance as the 2nd positional argument (besides self). By default the method does nothing, i.e. no animation is set for controls. To add animation you need to re-implement this method in your child class.

E.g:

def setAnimation(self, control):
    control.setAnimations([('WindowOpen', 'effect=fade start=0 end=100 time=1000',),
                            ('WindowClose', 'effect=fade start=100 end=0 time=1000',)])
onFocus(control)[source]

Catch focused controls.

Parameters:control – is an instance of xbmcgui.Control class.
addControl(control)[source]

Wrapper for xbmcgui.Window.addControl.

Parameters:control – the control to add.

Note

In most circumstances you should use placeControl.

Note

Only use this method if want to to place and element in a Group it using pixel coordinates

Example:

window.addControls(label)
addControls(controls)[source]

Wrapper for xbmcgui.Window.addControls.

Parameters:controls – iterable containing the controls to add.

Note

In most circumstances you should use placeControl.

Note

Only use this method if want to to place and element in a Group it using pixel coordinates

Example:

window.addControls([label, button])
removeControl(control)[source]

Remove a control from the window grid layout.

Parameters:control – control instance to be removed from the grid.

Example:

self.removeControl(self.label)
removeControls(controls)[source]

Remove multiple controls from the window grid layout.

Parameters:controls – an iterable of control instances to be removed from the grid.

Example:

self.removeControl(self.label)
onAction(action)[source]

Catch button actions.

Parameters:action – an instance of xbmcgui.Action class.
onControl(control)[source]

Catch activated controls.

Parameters:control – is an instance of xbmcgui.Control class.
class pyxbmct.addonwindow.AddonWindow(title=u'')[source]

Bases: pyxbmct.addonwindow.AbstractWindow

Top-level control window.

The control windows serves as a parent widget for other XBMC UI controls much like Tkinter.Tk or PyQt QWidget class. This is an abstract class which is not supposed to be instantiated directly and will raise exeptions. It is designed to be implemented in a grand-child class with the second inheritance from xbmcgui.Window or xbmcgui.WindowDialog in a direct child class.

This class provides a control window with a background and a header similar to top-level widgets of desktop UI frameworks.

Warning

This is an abstract class and is not supposed to be instantiated directly!

onControl(control)[source]

Catch activated controls.

Parameters:control – is an instance of xbmcgui.Control class.
setGeometry(width_, height_, rows_, columns_, pos_x=-1, pos_y=-1, padding=5)[source]

Set width, height, Grid layout, and coordinates (optional) for a new control window.

Parameters:
  • width – new window width in pixels.
  • height – new window height in pixels.
  • rows – # of rows in the Grid layout to place controls on.
  • columns – # of colums in the Grid layout to place controls on.
  • pos_x – (optional) x coordinate of the top left corner of the window.
  • pos_y – (optional) y coordinate of the top left corner of the window.
  • padding – (optional) padding between outer edges of the window

and controls placed on it.

If pos_x and pos_y are not privided, the window will be placed at the center of the screen.

Example:

self.setGeometry(400, 500, 5, 4)
setWindowTitle(title=u'')[source]

Set window title.

Warning

This method must be called AFTER (!!!) setGeometry(), otherwise there is some werid bug with all skin text labels set to the title text.

Example:

self.setWindowTitle('My Cool Addon')
getWindowTitle()[source]

Get window title.

class pyxbmct.addonwindow.BlankFullWindow[source]

Bases: pyxbmct.addonwindow.AbstractWindow, xbmcgui.Window

Addon UI container with a solid background.

This is a blank window with a black background and without any elements whatsoever. The decoration and layout are completely up to an addon developer. The window controls can hide under video or music visualization.

class pyxbmct.addonwindow.BlankDialogWindow[source]

Bases: pyxbmct.addonwindow.AbstractWindow, xbmcgui.WindowDialog

Addon UI container with a transparent background.

This is a blank window with a transparent background and without any elements whatsoever. The decoration and layout are completely up to an addon developer. The window controls are always displayed over video or music visualization.

class pyxbmct.addonwindow.AddonFullWindow(title='')[source]

Bases: pyxbmct.addonwindow.AddonWindow, xbmcgui.Window

Addon UI container with a solid background.

AddonFullWindow instance is displayed on top of the main background image – self.main_bg – and can hide behind a fullscreen video or music viaualisation.

Minimal example:

addon = AddonFullWindow('My Cool Addon')
addon.setGeometry(400, 300, 4, 3)
addon.doModal()
setBackground(image=u'')[source]

Set the main bacground to an image file.

Parameters:image – path to an image file as str.

Example:

self.setBackground('/images/bacground.png')
class pyxbmct.addonwindow.AddonDialogWindow(title='')[source]

Bases: pyxbmct.addonwindow.AddonWindow, xbmcgui.WindowDialog

Addon UI container with a transparent background.

Note

AddonDialogWindow instance is displayed on top of XBMC UI, including fullscreen video and music visualization.

Minimal example:

addon = AddonDialogWindow('My Cool Addon')
addon.setGeometry(400, 300, 4, 3)
addon.doModal()