Use reStructuredText in Theme

This commit is contained in:
Jon Tibble 2010-06-10 15:09:32 +01:00
parent 3a7ca9a185
commit 0e07c0f664
1 changed files with 81 additions and 31 deletions

View File

@ -64,47 +64,94 @@ class Theme(object):
""" """
Provide a class wrapper storing data from an XML theme Provide a class wrapper storing data from an XML theme
Attributes: ``name``
name : theme name Theme name
BackgroundMode : 1 - Transparent ``BackgroundMode``
1 - Opaque The behaviour of the background. Valid modes are:
- 0 - Transparent
- 1 - Opaque
BackgroundType : 0 - solid color ``BackgroundType``
1 - gradient color The content of the background. Valid types are:
2 - image - 0 - solid color
- 1 - gradient color
- 2 - image
BackgroundParameter1 : for image - filename ``BackgroundParameter1``
for gradient - start color Extra information about the background. The contents of this attribute
for solid - color depend on the BackgroundType:
BackgroundParameter2 : for image - border colour - image: image filename
for gradient - end color - gradient: start color
for solid - N/A - solid: color
BackgroundParameter3 : for image - N/A
for gradient - 0 -> vertical, 1 -> horizontal
FontName : name of font to use ``BackgroundParameter2``
FontColor : color for main font Extra information about the background. The contents of this attribute
FontProportion : size of font depend on the BackgroundType:
FontUnits : whether size of font is in <pixels> or <points> - image: border color
- gradient: end color
- solid: N/A
Shadow : 0 - no shadow, non-zero use shadow ``BackgroundParameter3``
ShadowColor : color for drop shadow Extra information about the background. The contents of this attribute
Outline : 0 - no outline, non-zero use outline depend on the BackgroundType:
OutlineColor : color for outline (or None for no outline) - image: N/A
- gradient: The direction of the gradient. Valid entries are:
- 0 -> vertical
- 1 -> horizontal
- solid: N/A
HorizontalAlign : 0 - left align ``FontName``
1 - right align Name of the font to use for the main font.
2 - centre align
VerticalAlign : 0 - top align ``FontColor``
1 - bottom align The color for the main font
2 - centre align
WrapStyle : 0 - normal ``FontProportion``
1 - lyrics The size of the main font
``FontUnits``
The units for FontProportion, either <pixels> or <points>
``Shadow``
The shadow type to apply to the main font.
- 0 - no shadow
- non-zero - use shadow
``ShadowColor``
Color for the shadow
``Outline``
The outline to apply to the main font
- 0 - no outline
- non-zero - use outline
``OutlineColor``
Color for the outline (or None if Outline is 0)
``HorizontalAlign``
The horizontal alignment to apply to text. Valid alignments are:
- 0 - left align
- 1 - right align
- 2 - centre align
``VerticalAlign``
The vertical alignment to apply to the text. Valid alignments are:
- 0 - top align
- 1 - bottom align
- 2 - centre align
``WrapStyle``
The wrap style to apply to the text. Valid styles are:
- 0 - normal
- 1 - lyrics
""" """
def __init__(self, xml): def __init__(self, xml):
""" """
Initialise a theme with data from xml Initialise a theme with data from xml
``xml``
The data to initialise the theme with
""" """
# init to defaults # init to defaults
self._set_from_XML(BLANK_STYLE_XML) self._set_from_XML(BLANK_STYLE_XML)
@ -125,6 +172,9 @@ class Theme(object):
def _set_from_XML(self, xml): def _set_from_XML(self, xml):
""" """
Set theme class attributes with data from XML Set theme class attributes with data from XML
``xml``
The data to apply to the theme
""" """
root = ElementTree(element=XML(xml)) root = ElementTree(element=XML(xml))
iter = root.getiterator() iter = root.getiterator()