Write Modify Page Footer Area
The following classes are used to modify the Area style values seen in Fig. 1166 of a Page style.
Default Page Style Dialog
Setup
General function used to run these examples.
Note that in order to apply a style, the document footer must be turned on as seen in Write Modify Page Footer.
from ooodev.format.writer.modify.page.header import Header, WriterStylePageKind
from ooodev.format.writer.modify.page.area import Color as FooterAreaColor
from ooodev.format import Styler
from ooodev.office.write import Write
from ooodev.utils.color import StandardColor
from ooodev.gui import GUI
from ooodev.loader.lo import Lo
def main() -> int:
with Lo.Loader(Lo.ConnectPipe()):
doc = Write.create_doc()
GUI.set_visible(doc=doc)
Lo.delay(300)
GUI.zoom(GUI.ZoomEnum.ENTIRE_PAGE)
footer_style = Footer(
on=True,
shared_first=True,
shared=True,
height=10.0,
spacing=3.0,
spacing_dyn=True,
margin_left=1.5,
margin_right=2.0,
style_name=WriterStylePageKind.STANDARD,
)
footer_color_style = HeaderAreaColor(
color=StandardColor.GOLD_LIGHT2, style_name=footer_style.prop_style_name
)
Styler.apply(doc, footer_style, footer_color_style)
style_obj = HeaderAreaColor.from_style(doc=doc, style_name=WriterStylePageKind.STANDARD)
assert style_obj.prop_style_name == str(WriterStylePageKind.STANDARD)
Lo.delay(1_000)
Lo.close_doc(doc)
return 0
if __name__ == "__main__":
SystemExit(main())
Area Color
The Color
class is used to modify the footer area color of a page style.
The result are seen in Fig. 1151 and Fig. 1152.
Setting Area Color
from ooodev.format.writer.modify.page.footer.area import Color as FooterAreaColor
# ... other code
footer_color_style = FooterAreaColor(
color=StandardColor.GOLD_LIGHT2, style_name=footer_style.prop_style_name
)
Styler.apply(doc, footer_style, footer_color_style)
Style results.
Getting color from a style
# ... other code
style_obj = FooterAreaColor.from_style(doc=doc, style_name=WriterStylePageKind.STANDARD)
assert style_obj.prop_style_name == str(WriterStylePageKind.STANDARD)
Area Gradient
Setting Area Gradient
The Gradient
class is used to modify the footer area gradient of a page style.
The result are seen in Fig. 1153 and Fig. 1154.
The PresetGradientKind
class is used to look up the presets of gradient for convenience.
from ooodev.format.writer.modify.page.footer.area import Gradient, PresetGradientKind
# ... other code
gradient_style = Gradient.from_preset(
preset=PresetGradientKind.DEEP_OCEAN, style_name=WriterStylePageKind.STANDARD
)
Styler.apply(doc, footer_style, gradient_style)
Style results.
Getting gradient from a style
# ... other code
style_obj = Gradient.from_style(doc=doc, style_name=WriterStylePageKind.STANDARD)
assert style_obj.prop_style_name == str(WriterStylePageKind.STANDARD)
Area Image
Setting Area Image
The Img
class is used to modify the footer area image of a page style.
The result are seen in Fig. 1155 and Fig. 1156.
The PresetImageKind
class is used to look up the presets of image for convenience.
from ooodev.format.writer.modify.page.footer.area import Img as FooterAreaImg, PresetImageKind
# ... other code
img_style = FooterAreaImg.from_preset(
preset=PresetImageKind.COLOR_STRIPES, style_name=WriterStylePageKind.STANDARD
)
Styler.apply(doc, footer_style, img_style)
Style results.
Getting image from a style
# ... other code
style_obj = FooterAreaImg.from_style(doc=doc, style_name=WriterStylePageKind.STANDARD)
assert style_obj.prop_style_name == str(WriterStylePageKind.STANDARD)
Area Pattern
Setting Area Pattern
The Pattern
class is used to modify the footer area pattern of a page style.
The result are seen in Fig. 1157 and Fig. 1158.
The PresetPatternKind
class is used to look up the presets of pattern for convenience.
from ooodev.format.writer.modify.page.footer.area import Pattern as FooterStylePattern, PresetPatternKind
# ... other code
pattern_style = FooterStylePattern.from_preset(
preset=PresetPatternKind.HORIZONTAL_BRICK, style_name=WriterStylePageKind.STANDARD
)
Styler.apply(doc, footer_style, pattern_style)
Style results.
Getting pattern from a style
# ... other code
style_obj = FooterStylePattern.from_style(doc=doc, style_name=WriterStylePageKind.STANDARD)
assert style_obj.prop_style_name == str(WriterStylePageKind.STANDARD)
Area Hatch
Setting Area Hatch
The Hatch
class is used to modify the footer area hatch of a page style.
The result are seen in Fig. 1159 and Fig. 1160.
The PresetHatchKind
class is used to look up the presets of hatch for convenience.
from ooodev.format.writer.modify.page.footer.area import Hatch as FooterStyleHatch, PresetHatchKind
# ... other code
hatch_style = FooterStyleHatch.from_preset(
preset=PresetHatchKind.RED_45_DEGREES_NEG_TRIPLE, style_name=WriterStylePageKind.STANDARD
)
Styler.apply(doc, footer_style, hatch_style)
Style results.
Getting hatch from a style
# ... other code
style_obj = FooterStyleHatch.from_style(doc=doc, style_name=WriterStylePageKind.STANDARD)
assert style_obj.prop_style_name == str(WriterStylePageKind.STANDARD)
Related Topics
See also