StyleSet

StyleSet(widget, [parent]) -> StyleSet object

A styleset is a collection of style options grouped together for a specific event for a widget. Each widget has an dictionary named "stylesets" which contains several stylesets. For example:

{"disabled":styleset, "hover":styleset, "default":styleset,
        "focused":styleset, "down":styleset}

When the widget is hovered for example it will use stylesets["hover"] At any time you can change a styling option for a widget by doing something like this:

mywidget.stylesets["hover"]["color"] = (255,10,10)

WARNING: Do not use the color (0,0,0)! It is used as the surface color key. That means that if you use it it won't show up! If you want to use the color black, use (5,5,5) or something (which is indistinguishable from pure black). This applies to font colors sometimes. :P

Style options

option value
padding 8 4 4 5 | 4 5 | 10
padding-top 3
padding-right 3
padding-bottom 3
padding-left 3
color (255,255,255)
font-weight normal | bold
font-family Verra.ttf
font-size 12
effect pulsate 5
width 300
height 200
x 57
y 102
position relative | absolute
bgcolor (200,0,0)
bgimage image.png repeat|repeat-x|repeat-y|no-repeat|slice
border (0,250,20) 3
spacing 12 # For certain container widgets.
opacity 25 # Alpha value. Valid otpions between 0 and 255.
antialias 1 | 0
align left | right | center
valign top | bottom | center

Something to note about align and valign. When they are changed from their default values (top and left), the x and y values act as an offset. So if you are aligning a widget center and have an x value of 100, the widget will display 100 pixels to the right of the center of it's parent (or container) widget.

Also, aligning only takes effect when positioning is relative (which is default).

Arguments

widget
The widget this styleset is for.
parent
Another styleset that this styleset should inherit from.

StyleSet.surf

StyleSet.surf -> pygame.Surface

The surface generated from the styling.

StyleSet.apply

StyleSet.apply(surf, option, values) -> pygame.Surface

Applies styling to surf. If you are just wanting to change a style option, use:

StyleSet["option"] = values

This function is mainly for internal use.