Styling
Styling in GUI is done via Style objects. These are
are dicts with some magic. They can have a fallback ie. if a certain
style is not found, the request will be passed to the parent/fallback style
object. This way, you can have one general style that all individual styles
use as fallback. This general style is GUI.style. You can also define
a widgetclassname*_*stylename ie layer_image to set an image for all
layer instances. The last way to influence a style of a widget is do implement
the :meth:~gui.base.Widget.get_suffix method in the widget class. This
method can return a suffix that is added with an underscore to the stylename.
Order of what happens when requesting a style
- If no suffix is given and widget.get_suffix returns a suffix:
Start at 1.) with stylename*_*suffix
- Prefix the stylename with Widget.style_class_name.lower() or
(if it is None) the lowercase class name, connected with an underscore.
Example: “image” style for Layer will first search for “layer_image”.
- Search the stylename without any prefix.
- Ask the fallback style (this won’t use suffix again).
API
Styles are callable and you should always use this to get a style attribute.
method: | Style.__call__(name, widget, [default=None, suffix=None])
type name: | String |
param name: | Name of the requested style attribute. |
type widget: | Widget |
param widget: | The widget that will use the style. |
param default: | Default value that will be returned if the requested
attribute is not defined. |
type suffix: | None, False, String |
param suffix: | If it is a string, it will be added with an underscore to name
before searching. Then, if this is not defined, name will be used.
If it is None, the return value of widget.get_suffix() will be
used as suffix.
If it is False, no suffix will be used. |
|