pyxbmct.addoncontrols

This module contains all the controls of the PyXBMCt framework

Classes

Button(label[, focusTexture, …]) ControlButton class.
Edit(label[, font, textColor, …]) ControlEdit class.
FadeLabel([font, textColor, _alignment]) Control that scrolls label text.
Image(filename[, aspectRatio, colorDiffuse]) ControlImage class.
Label(label[, font, textColor, …]) ControlLabel class.
List([font, textColor, buttonTexture, …]) ControlList class.
RadioButton(label[, focusTexture, …]) ControlRadioButton class.
Group(rows, columns) ControlGroup class.
Skin
Slider([textureback, texture, texturefocus, …]) ControlSlider class.
TextBox([font, textColor]) ControlTextBox class
ControlWithConnectCallback Abstract mixin class for controls that require a callback before events are connected to them
ControlWithPlacedCallback Abstract mixin class for controls that require a callback after they have been placed
ControlWithRemovedCallback Abstract mixin class for controls that require a callback before they are removed
ControlWithFocusedCallback Abstract mixin class for controls that require a callback before events are connected to them
class pyxbmct.addoncontrols.ControlWithConnectCallback[source]

Bases: object

Abstract mixin class for controls that require a callback before events are connected to them

class pyxbmct.addoncontrols.ControlWithPlacedCallback[source]

Bases: object

Abstract mixin class for controls that require a callback after they have been placed

class pyxbmct.addoncontrols.ControlWithRemovedCallback[source]

Bases: object

Abstract mixin class for controls that require a callback before they are removed

class pyxbmct.addoncontrols.ControlWithFocusedCallback[source]

Bases: object

Abstract mixin class for controls that require a callback before events are connected to them

class pyxbmct.addoncontrols.ControlMixin[source]

Bases: object

Basic control functionality mixin.

Provides utility methods and wrappers for some existing methods to support PyXBMCt

Warning

This is a mixin class and is not supposed to be instantiated directly!

isEnabled()[source]

Determine if a control is enabled or not.

Example:

enabled = self.isEnabled()
setEnabled(is_enabled)[source]

Set whether the control is enabled or not.

Parameters:is_enabled – boolean to determine if the control is enabled.

Example:

self.setEnabled(False)
getMidpoint()[source]

Get the (x,y) coordinates of the controls midpoint.

Example:

x, y = self.getMidpoint()
class pyxbmct.addoncontrols.Label(label, font=None, textColor=None, disabledColor=None, alignment=0, hasPath=False, angle=0)[source]

Bases: pyxbmct.addoncontrols.ControlMixin, 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.addoncontrols.FadeLabel(font=None, textColor=None, _alignment=0)[source]

Bases: pyxbmct.addoncontrols.ControlMixin, 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.addoncontrols.TextBox(font=None, textColor=None)[source]

Bases: pyxbmct.addoncontrols.ControlMixin, 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.addoncontrols.Image(filename, aspectRatio=0, colorDiffuse=None)[source]

Bases: pyxbmct.addoncontrols.ControlMixin, 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.addoncontrols.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.addoncontrols.ControlMixin, 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.addoncontrols.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.addoncontrols.ControlMixin, 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.addoncontrols.Edit(label, font=None, textColor=None, disabledColor=None, _alignment=0, focusTexture=None, noFocusTexture=None, isPassword=False)[source]

Bases: pyxbmct.addoncontrols.ControlMixin, xbmcgui.ControlEdit

ControlEdit class. Edit is not supported on Xbox using the Python API

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.addoncontrols.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.addoncontrols.ControlMixin, 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.addoncontrols.Group(rows, columns)[source]

Bases: pyxbmct.addoncontrols.ControlMixin, xbmcgui.ControlGroup, pyxbmct.abstractgrid.AbstractGrid, pyxbmct.addoncontrols.ControlWithPlacedCallback, pyxbmct.addoncontrols.ControlWithFocusedCallback, pyxbmct.addoncontrols.ControlWithRemovedCallback

ControlGroup class.

Implements a secondary grid (with its own coordinate system) that controls can be placed in. Allowing for finer control over where controls are placed in a window.

Parameters:
  • rows – integer - the number of rows in the grid
  • columns – integer - the number of columns in the grid

Note

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

Warning

You must place Group in a window before adding controls to it!

Example:

self.group = Group(1,2)
getRows()[source]

Get grid rows count.

getColumns()[source]

Get grid columns count.

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)
removeAllChildren()[source]

Removes all the Group’s children (and all their children) from the window.

Example:

group.removeAllChildren()
setVisible(is_visible)[source]

Sets the group (and it all its current children) to be either visible or invisible.

Parameters:is_visible – determines whether or the group and its current children should be visible or not.

Example:

group.setVisible(False)
setVisibleCondition(is_visible, allow_hidden_focus=False)[source]

See the XBMC documentation

setEnabled(is_enabled)[source]

Sets the group (and it all its current children) to be either enabled or disabled.

Parameters:is_enabled – determines whether or the group and its current children should be enabled or not.

Example:

group.setVisible(setEnabled)
setEnableCondition(is_enabled)[source]

See the XBMC documentation

class pyxbmct.addoncontrols.Slider(textureback=None, texture=None, texturefocus=None, orientation=xbmcgui.HORIZONTAL)[source]

Bases: pyxbmct.addoncontrols.ControlMixin, 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()