enaml.styling
Classes
A declarative class for defining a style field setter. |
|
A mixin class for defining stylable declarative objects. |
|
A declarative class for defining a style sheet style. |
|
An object which manages the styling caches. |
|
A declarative class for defining a widget style sheet. |
- class enaml.styling.Setter(parent=None, **kwargs)[source]
Bases:
Declarative
A declarative class for defining a style field setter.
A
Setter
is declared as a child of aStyle
. It defines the value to be applied to a style field.- field
The style field to which this setter applies.
- value
The value to apply to the style field.
- destroy()[source]
A reimplemented destructor.
This will notify the
StyleCache
when the setter is destroyed.
- class enaml.styling.Stylable(parent=None, **kwargs)[source]
Bases:
Declarative
A mixin class for defining stylable declarative objects.
This class can be used as a mixin with any
Declarative
class which wishes to support style sheets.- style_class
The style class to which this item belongs. Multiple classes can be separated with whitespace. An empty string indicates the widget does not belong to any style class.
- destroy()[source]
A reimplemented destructor.
This will notify the
StyleCache
when the stylable item is destroyed.
- style_sheet()[source]
Get the
StyleSheet
defined on the item.- Returns:
result – The last
StyleSheet
child defined on the item, or None if the item has no such child.- Return type:
StyleSheet
or None
- restyle()[source]
Restyle the object.
This method will be called when the style dependencies for the object have changed. It should be reimplemented in a subclass to take appropriate action for the restyle.
- parent_changed(old, new)[source]
A reimplemented parent changed event handler.
This will notify the
StyleCache
if the parent of the item has changed.
- child_added(child)[source]
A reimplemented child added event handler.
This will notify the
StyleCache
if theStyleSheet
children of the item have changed.
- child_removed(child)[source]
A reimplemented child removed event handler.
This will notify the
StyleCache
if theStyleSheet
children of the item have changed.
- class enaml.styling.Style(parent=None, **kwargs)[source]
Bases:
Declarative
A declarative class for defining a style sheet style.
A
Style
is declared as a child of aStyleSheet
. It uses childSetter
objects to define the style fields to apply to widgets which are a match for the style.A
Style
may have an arbitrary number ofSetter
children.- element
The type name of the element which will match the style. An empty string will match all elements. Multiple elements can be separated by a comma and will match using logical OR semantics.
- style_class
The name of the widget style class which will match the style. An empty string will match all style classes. Multiple classes can be separated by a comma and will match using logical OR semantics.
- object_name
The object name of the widget which will match the style. An empty string will match all object names. Multiple object names can be separated by a comma and will match using logical OR semantics.
- pseudo_class
The pseudo-class which must be active for the style to apply. An empty string will apply the syle for all pseudo-classes. Multiple classes can be separated by a colon will match using logical AND semantics. Commas can be used to separate multiple classes which will match using logical OR semantics.
- pseudo_element
The pseudo-element to which the style applies. An empty string indicates the style applies to the primary element. Multiple pseudo elements can be separated comma and match using logical OR semantics.
- destroy()[source]
A reimplemented destructor.
This will notify the
StyleCache
when the style is destroyed.
- child_added(child)[source]
A reimplemented child added event handler.
This will notify the
StyleCache
if theSetter
children of the style have changed.
- child_removed(child)[source]
A reimplemented child removed event handler.
This will notify the
StyleCache
if theSetter
children of the style have changed.
- class enaml.styling.StyleCache(*args, **kwargs)[source]
Bases:
object
An object which manages the styling caches.
All interaction with this class is through public class methods. This class should be used by code which implements the styling for a stylable item. The public API methods can be used to query for the Style object which matchs a
Stylable
item.- classmethod style_sheets(item)[source]
Get the
StyleSheet
objects which apply to an item.- Parameters:
item (
Stylable
) – The stylable item of interest.- Returns:
result – The
StyleSheet
objects which apply to the item, in order of ascending precedence.- Return type:
- classmethod toolkit_setter(setter, translate)[source]
Get the toolkit representation of a setter.
This method will return the cached toolkit setter, if available, or invoke the translator to create the cached setter. The cached toolkit setter will be cleared when the setter is invalidated.
- Parameters:
- Returns:
result – The toolkit representation of the setter.
- Return type:
- __weakref__
list of weak references to the object (if defined)
- class enaml.styling.StyleSheet(parent=None, **kwargs)[source]
Bases:
Declarative
A declarative class for defining a widget style sheet.
A
StyleSheet
is declared as a child of aStylable
widget. It uses childStyle
objects to apply styling to its parent widget and all of the widget’s decendents. AStyleSheet
can also be provided to the globalApplication
, in which case the styling will be applied to all stylable widgets. The effective style sheet for a widget is the union of all its ancestor style sheets plus the application style sheet.A
StyleSheet
may have an arbitrary number ofStyle
children. The child style objects are applied to a widget in the order of their match specificity within the style sheet.- destroy()[source]
A reimplemented destructor.
This will notify the
StyleCache
when the style sheet is destroyed.
- child_added(child)[source]
A reimplemented child added event handler.
This will notify the
StyleCache
if theStyle
children of the style sheet have changed.
- child_removed(child)[source]
A reimplemented child removed event handler.
This will notify the
StyleCache
if theStyle
children of the style sheet have changed.