pyxbmct.addonwindow

This module contains all classes and constants of 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.
Button(label[, focusTexture, …]) ControlButton class.
DialogWindowMixin([existingWindowId]) An abstract class to define window event processing.
Edit(label[, font, textColor, …]) ControlEdit class.
FadeLabel([font, textColor, _alignment]) Control that scrolls label text.
FullWindowMixin([existingWindowId]) An abstract class to define window event processing.
Image(filename[, aspectRatio, colorDiffuse]) ControlImage class.
Label(label[, font, textColor, …]) ControlLabel class.
List([font, textColor, buttonTexture, …]) ControlList class.
RadioButton(label[, focusTexture, …]) ControlRadioButton class.
Skin() Skin class
Slider([textureback, texture, texturefocus, …]) ControlSlider class.
TextBox([font, textColor]) ControlTextBox class

Exceptions

AddonWindowError Custom exception
pyxbmct.addonwindow.ALIGN_LEFT = 0

Align left

pyxbmct.addonwindow.ALIGN_RIGHT = 1

Align right

pyxbmct.addonwindow.ALIGN_CENTER_X = 2

Align center horisontally

pyxbmct.addonwindow.ALIGN_CENTER_Y = 4

Align center vertically

pyxbmct.addonwindow.ALIGN_CENTER = 6

Align center by both axis

pyxbmct.addonwindow.ALIGN_TRUNCATED = 8

Align truncated

pyxbmct.addonwindow.ALIGN_JUSTIFY = 10

Align justify

pyxbmct.addonwindow.ACTION_PREVIOUS_MENU = 10

ESC action

pyxbmct.addonwindow.ACTION_NAV_BACK = 92

Backspace action

pyxbmct.addonwindow.ACTION_MOVE_LEFT = 1

Left arrow key

pyxbmct.addonwindow.ACTION_MOVE_RIGHT = 2

Right arrow key

pyxbmct.addonwindow.ACTION_MOVE_UP = 3

Up arrow key

pyxbmct.addonwindow.ACTION_MOVE_DOWN = 4

Down arrow key

pyxbmct.addonwindow.ACTION_MOUSE_WHEEL_UP = 104

Mouse wheel up

pyxbmct.addonwindow.ACTION_MOUSE_WHEEL_DOWN = 105

Mouse wheel down

pyxbmct.addonwindow.ACTION_MOUSE_DRAG = 106

Mouse drag

pyxbmct.addonwindow.ACTION_MOUSE_MOVE = 107

Mouse move

pyxbmct.addonwindow.ACTION_MOUSE_LEFT_CLICK = 100

Mouse click

exception pyxbmct.addonwindow.AddonWindowError[source]

Bases: exceptions.Exception

Custom exception

class pyxbmct.addonwindow.Label(label, font=None, textColor=None, disabledColor=None, alignment=0, hasPath=False, angle=0)[source]

Bases: xbmcgui.ControlLabel

ControlLabel class.

Implements a simple text label.

Parameters:
  • label (str) – text string
  • font (str) – font used for label text. (e.g. 'font13')
  • textColor (str) – hex color code of enabled label’s label. (e.g. '0xFFFFFFFF')
  • disabledColor (str) – hex color code of disabled label’s label. (e.g. '0xFFFF3300')
  • alignment (int) – alignment of label. Note: see xbfont.h
  • hasPath (bool) – True = stores a path / False = no path.
  • angle (int) – angle of control. (+ rotates CCW, - rotates CW)

Note

After you create the control, you need to add it to the window with placeControl().

Example:

self.label = Label('Status', angle=45)
class pyxbmct.addonwindow.FadeLabel(font=None, textColor=None, _alignment=0)[source]

Bases: xbmcgui.ControlFadeLabel

Control that scrolls label text.

Implements a text label that can auto-scroll very long text.

Parameters:
  • font (str) – font used for label text. (e.g. 'font13')
  • textColor (str) – hex color code of fadelabel’s labels. (e.g. '0xFFFFFFFF')
  • _alignment (int) – alignment of label. Note: see xbfont.h

Note

After you create the control, you need to add it to the window with placeControl().

Example:

self.fadelabel = FadeLabel(textColor='0xFFFFFFFF')
class pyxbmct.addonwindow.TextBox(font=None, textColor=None)[source]

Bases: xbmcgui.ControlTextBox

ControlTextBox class

Implements a box for displaying multi-line text. Long text is truncated from below. Also supports auto-scrolling.

Parameters:
  • font (str) – font used for text. (e.g. 'font13')
  • textColor (str) – hex color code of textbox’s text. (e.g. '0xFFFFFFFF')

Note

After you create the control, you need to add it to the window with placeControl().

Example:

self.textbox = TextBox(textColor='0xFFFFFFFF')
class pyxbmct.addonwindow.Image(filename, aspectRatio=0, colorDiffuse=None)[source]

Bases: xbmcgui.ControlImage

ControlImage class.

Implements a box for displaying .jpg, .png, and .gif images.

Parameters:
  • filename (str) – path or URL to an image file.
  • aspectRatio (int) – (values: 0 = stretch (default), 1 = scale up (crops), 2 = scale down (black bars)
  • colorDiffuse (str) – for example, '0xC0FF0000' (red tint)

Note

After you create the control, you need to add it to the window with placeControl().

Example:

self.image = Image('d:\images\picture.jpg', aspectRatio=2)
class pyxbmct.addonwindow.Button(label, focusTexture=None, noFocusTexture=None, textOffsetX=CONTROL_TEXT_OFFSET_X, textOffsetY=CONTROL_TEXT_OFFSET_Y, alignment=4, font=None, textColor=None, disabledColor=None, angle=0, shadowColor=None, focusedColor=None)[source]

Bases: pyxbmct.addonwindow.CompareMixin, xbmcgui.ControlButton

ControlButton class.

Implements a clickable button.

Parameters:
  • label (str) – button caption
  • focusTexture (str) – filename for focus texture.
  • noFocusTexture (str) – filename for no focus texture.
  • textOffsetX (int) – x offset of label.
  • textOffsetY (int) – y offset of label.
  • alignment (int) – alignment of label. Note: see xbfont.h
  • font (str) – font used for label text. (e.g. 'font13')
  • textColor (str) – hex color code of enabled button’s label. (e.g. '0xFFFFFFFF')
  • disabledColor (str) – hex color code of disabled button’s label. (e.g. '0xFFFF3300')
  • angle (int) – angle of control. (+ rotates CCW, - rotates CW)
  • shadowColor (str) – hex color code of button’s label’s shadow. (e.g. '0xFF000000')
  • focusedColor (str) – hex color code of focused button’s label. (e.g. '0xFF00FFFF')

Note

After you create the control, you need to add it to the window with placeControl().

Example:

self.button = Button('Status', font='font14')
class pyxbmct.addonwindow.RadioButton(label, focusTexture=None, noFocusTexture=None, textOffsetX=None, textOffsetY=None, _alignment=None, font=None, textColor=None, disabledColor=None, angle=None, shadowColor=None, focusedColor=None, focusOnTexture=None, noFocusOnTexture=None, focusOffTexture=None, noFocusOffTexture=None)[source]

Bases: pyxbmct.addonwindow.CompareMixin, xbmcgui.ControlRadioButton

ControlRadioButton class.

Implements a 2-state switch.

Parameters:
  • label – label text.
  • focusTexture (str) – filename for focus texture.
  • noFocusTexture (str) – filename for no focus texture.
  • textOffsetX (int) – x offset of label.
  • textOffsetY (int) – y offset of label.
  • _alignment (int) – alignment of label - *Note, see xbfont.h
  • font (str) – font used for label text. (e.g. ‘font13’)
  • textColor (str) – hexstring – color of enabled radio button’s label. (e.g. ‘0xFFFFFFFF’)
  • disabledColor (str) – hexstring – color of disabled radio button’s label. (e.g. ‘0xFFFF3300’)
  • angle (int) – angle of control. (+ rotates CCW, - rotates CW)
  • shadowColor (str) – hexstring – color of radio button’s label’s shadow. (e.g. ‘0xFF000000’)
  • focusedColor (str) – hexstring – color of focused radio button’s label. (e.g. ‘0xFF00FFFF’)
  • focusOnTexture (str) – filename for radio focused/checked texture.
  • noFocusOnTexture (str) – filename for radio not focused/checked texture.
  • focusOffTexture (str) – filename for radio focused/unchecked texture.
  • noFocusOffTexture (str) – filename for radio not focused/unchecked texture.
Type:

str or unicode

Note

To customize RadioButton all 4 abovementioned textures need to be provided.

Note

After you create the control, you need to add it to the window with placeControl().

Example:

self.radiobutton = RadioButton('Status', font='font14')
class pyxbmct.addonwindow.Edit(label, font=None, textColor=None, disabledColor=None, _alignment=0, focusTexture=None, noFocusTexture=None, isPassword=False)[source]

Bases: pyxbmct.addonwindow.CompareMixin, xbmcgui.ControlEdit

ControlEdit class.

Implements a clickable text entry field with an on-screen keyboard.

Parameters:
  • label (str or unicode) – text string.
  • font (str) – [opt] font used for label text. (e.g. ‘font13’)
  • textColor (str) – [opt] hexstring – color of enabled label’s label. (e.g. ‘0xFFFFFFFF’)
  • disabledColor (str) – [opt] hexstring – color of disabled label’s label. (e.g. ‘0xFFFF3300’)
  • _alignment (int) – [opt] lignment of label - *Note, see xbfont.h
  • focusTexture (str) – [opt] filename for focus texture.
  • noFocusTexture (str) – [opt] filename for no focus texture.
  • isPassword (bool) – [opt] if True, mask text value.

Note

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. After you create the control, you need to add it to the window with placeControl().

Example:

self.edit = Edit('Status')
class pyxbmct.addonwindow.List(font=None, textColor=None, buttonTexture=None, buttonFocusTexture=None, selectedColor=None, _imageWidth=10, _imageHeight=10, _itemTextXOffset=10, _itemTextYOffset=2, _itemHeight=27, _space=2, _alignmentY=4)[source]

Bases: pyxbmct.addonwindow.CompareMixin, xbmcgui.ControlList

ControlList class.

Implements a scrollable list of items.

Parameters:
  • font – string - font used for items label. (e.g. ‘font13’)
  • textColor – hexstring - color of items label. (e.g. ‘0xFFFFFFFF’)
  • buttonTexture – string - filename for no focus texture.
  • buttonFocusTexture – string - filename for focus texture.
  • selectedColor – integer - x offset of label.
  • _imageWidth – integer - width of items icon or thumbnail.
  • _imageHeight – integer - height of items icon or thumbnail.
  • _itemTextXOffset – integer - x offset of items label.
  • _itemTextYOffset – integer - y offset of items label.
  • _itemHeight – integer - height of items.
  • _space – integer - space between items.
  • _alignmentY – integer - Y-axis alignment of items label - *Note, see xbfont.h

Note

After you create the control, you need to add it to the window with placeControl().

Example:

self.cList = List('font14', space=5)
class pyxbmct.addonwindow.Slider(textureback=None, texture=None, texturefocus=None, orientation=xbmcgui.HORIZONTAL)[source]

Bases: pyxbmct.addonwindow.CompareMixin, xbmcgui.ControlSlider

ControlSlider class.

Implements a movable slider for adjusting some value.

Parameters:
  • textureback – string – image filename.
  • texture – string – image filename.
  • texturefocus – string – image filename.
  • orientation – int – slider orientation

Note

After you create the control, you need to add it to the window with placeControl().

Example:

self.slider = Slider()
class pyxbmct.addonwindow.AbstractWindow[source]

Bases: object

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!

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)
placeControl(control, row, column, rowspan=1, columnspan=1, pad_x=5, pad_y=5)[source]

Place a control within the window grid layout.

Parameters:
  • control – control instance to be placed in the grid.
  • row – row number where to place the control (starts from 0).
  • column – column number where to place the control (starts from 0).
  • rowspan – set when the control needs to occupy several rows.
  • columnspan – set when the control needs to occupy several columns.
  • pad_x – horisontal padding.
  • pad_y – vertical padding.
Raises:

AddonWindowError if a grid has not yet been set.

Use pad_x and pad_y to adjust control’s aspect. Negative padding values can be used to make a control overlap with grid cells next to it, if necessary.

Example:

self.placeControl(self.label, 0, 1)
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.

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.
connect(event, callable)[source]

Connect an event to a function.

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

An event can be an inctance 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.

callable 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, function)[source]

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

See connect() docstring for more info.

disconnect(event)[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.
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)[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.
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',)])
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!

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.FullWindowMixin(existingWindowId=-1)[source]

Bases: xbmcgui.Window

An abstract class to define window event processing.

onAction(action)[source]

Catch button actions.

action is an instance of xbmcgui.Action class.

onControl(control)[source]

Catch activated controls.

control is an instance of xbmcgui.Control class.

class pyxbmct.addonwindow.DialogWindowMixin(existingWindowId=-1)[source]

Bases: xbmcgui.WindowDialog

An abstract class to define window event processing.

onAction(action)[source]

Catch button actions.

action is an instance of class:xbmcgui.Action class.

onControl(control)[source]

Catch activated controls.

control is an instance of xbmcgui.Control class.

class pyxbmct.addonwindow.BlankFullWindow[source]

Bases: pyxbmct.addonwindow.FullWindowMixin, pyxbmct.addonwindow.AbstractWindow

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.DialogWindowMixin, pyxbmct.addonwindow.AbstractWindow

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.FullWindowMixin, pyxbmct.addonwindow.AddonWindow

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.DialogWindowMixin, pyxbmct.addonwindow.AddonWindow

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()