Styling
momapy.styling
Classes and functions for styling layout elements using style sheets
Classes:
Name | Description |
---|---|
ChildSelector |
Class for child selectors |
ClassSelector |
Class for class selectors |
DescendantSelector |
Class for descendant selectors |
IdSelector |
Class for id selectors |
OrSelector |
Class for or selectors |
Selector |
Abstract class for selectors |
StyleCollection |
Class for style collections |
StyleSheet |
Class for style sheets |
TypeSelector |
Class for type selectors |
Functions:
Name | Description |
---|---|
apply_style_collection |
Apply a style collection to a layout element |
apply_style_sheet |
Apply a style sheet to a layout element or (layout of) a map |
combine_style_sheets |
Merge a collection of style sheets into a unique style sheet and return it |
ChildSelector
dataclass
Bases: Selector
Class for child selectors
Methods:
Name | Description |
---|---|
select |
Return |
select
select(obj: LayoutElement | LayoutElementBuilder, ancestors: Collection[LayoutElement | LayoutElementBuilder])
Return true
if the given layout element satisfies the selector, and false
otherwise
Source code in src/momapy/styling.py
ClassSelector
dataclass
Bases: Selector
Class for class selectors
Methods:
Name | Description |
---|---|
select |
Return |
select
select(obj: LayoutElement | LayoutElementBuilder, ancestors: Collection[LayoutElement | LayoutElementBuilder])
Return true
if the given layout element satisfies the selector, and false
otherwise
Source code in src/momapy/styling.py
DescendantSelector
dataclass
Bases: Selector
Class for descendant selectors
Methods:
Name | Description |
---|---|
select |
Return |
select
select(obj: LayoutElement | LayoutElementBuilder, ancestors: Collection[LayoutElement | LayoutElementBuilder])
Return true
if the given layout element satisfies the selector, and false
otherwise
Source code in src/momapy/styling.py
IdSelector
dataclass
Bases: Selector
Class for id selectors
Methods:
Name | Description |
---|---|
select |
Return |
select
select(obj: LayoutElement | LayoutElementBuilder, ancestors: Collection[LayoutElement | LayoutElementBuilder])
Return true
if the given layout element satisfies the selector, and false
otherwise
Source code in src/momapy/styling.py
OrSelector
dataclass
OrSelector(selectors: tuple[Selector])
Bases: Selector
Class for or selectors
Methods:
Name | Description |
---|---|
select |
Return |
select
select(obj: LayoutElement | LayoutElementBuilder, ancestors: Collection[LayoutElement | LayoutElementBuilder])
Return true
if the given layout element satisfies the selector, and false
otherwise
Source code in src/momapy/styling.py
Selector
dataclass
Bases: object
Abstract class for selectors
Methods:
Name | Description |
---|---|
select |
Return |
select
abstractmethod
select(obj: LayoutElement | LayoutElementBuilder, ancestors: Collection[LayoutElement | LayoutElementBuilder]) -> bool
Return true
if the given layout element satisfies the selector, and false
otherwise
Source code in src/momapy/styling.py
StyleCollection
Bases: dict
Class for style collections
StyleSheet
Bases: dict
Class for style sheets
Methods:
Name | Description |
---|---|
from_file |
Read and return a style sheet from a file |
from_files |
Read and return a style sheet from a collection of files |
from_string |
Read and return a style sheet from a string |
from_file
classmethod
from_file(file_path: str) -> StyleSheet
from_files
classmethod
from_files(file_paths: Collection[str]) -> StyleSheet
Read and return a style sheet from a collection of files
Source code in src/momapy/styling.py
from_string
classmethod
from_string(s: str) -> StyleSheet
TypeSelector
dataclass
Bases: Selector
Class for type selectors
Methods:
Name | Description |
---|---|
select |
Return |
select
select(obj: LayoutElement | LayoutElementBuilder, ancestors: Collection[LayoutElement | LayoutElementBuilder])
Return true
if the given layout element satisfies the selector, and false
otherwise
Source code in src/momapy/styling.py
apply_style_collection
apply_style_collection(layout_element: LayoutElement | LayoutElementBuilder, style_collection: StyleCollection, strict: bool = True) -> LayoutElement | LayoutElementBuilder
Apply a style collection to a layout element
Source code in src/momapy/styling.py
apply_style_sheet
apply_style_sheet(map_or_layout_element: Map | LayoutElement | MapBuilder | LayoutElementBuilder, style_sheet: StyleSheet, strict: bool = True, ancestors: Collection[LayoutElement | LayoutElementBuilder] = None) -> Map | LayoutElement | LayoutElementBuilder | MapBuilder
Apply a style sheet to a layout element or (layout of) a map
Source code in src/momapy/styling.py
combine_style_sheets
combine_style_sheets(style_sheets: Collection[StyleSheet]) -> StyleSheet
Merge a collection of style sheets into a unique style sheet and return it