StyleSet
StyleSet(widget, [parent]) -> StyleSet objectA 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 (0,0,1) or something (which is indistinguishable from pure black). This doesn't apply to font colors.
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. |
Arguments
- widget
- The widget this styleset is for.
- parent
- Another styleset that this styleset should inherit from.
StyleSet.surf
StyleSet.surf -> pygame.SurfaceThe surface generated from the styling.
StyleSet.apply
StyleSet.apply(surf, option, values) -> pygame.SurfaceApplies styling to surf. If you are just wanting to change a style option, use:
StyleSet["option"] = values
This function is mainly for internal use.