Write Modify Page Header Area
The following classes are used to modify the Area style values seen in Fig. 1144 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 header must be turned on as seen in Write Modify Page Header.
from ooodev.format.writer.modify.page.header import Header, WriterStylePageKind
from ooodev.format.writer.modify.page.header.area import Color as PageAreaColor
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)
header_style = Header(
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,
)
header_color_style = HeaderAreaColor(
color=StandardColor.GOLD_LIGHT2, style_name=header_style.prop_style_name
)
Styler.apply(doc, header_style, header_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 header area color of a page style.
The result are seen in Fig. 1129 and Fig. 1130.
Setting Area Color
from ooodev.format.writer.modify.page.header.area import Color as HeaderAreaColor
# ... other code
header_color_style = HeaderAreaColor(
color=StandardColor.GOLD_LIGHT2, style_name=header_style.prop_style_name
)
Styler.apply(doc, header_style, header_color_style)
Style results.
Getting color from a style
# ... other code
style_obj = HeaderAreaColor.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 header area gradient of a page style.
The result are seen in Fig. 1131 and Fig. 1132.
The PresetGradientKind
class is used to look up the presets of gradient for convenience.
from ooodev.format.writer.modify.page.header.area import Gradient, PresetGradientKind
# ... other code
gradient_style = Gradient.from_preset(
preset=PresetGradientKind.DEEP_OCEAN, style_name=WriterStylePageKind.STANDARD
)
Styler.apply(doc, header_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 header area image of a page style.
The result are seen in Fig. 1133 and Fig. 1134.
The PresetImageKind
class is used to look up the presets of image for convenience.
from ooodev.format.writer.modify.page.header.area import Img as HeaderAreaImg, PresetImageKind
# ... other code
img_style = HeaderAreaImg.from_preset(
preset=PresetImageKind.COLOR_STRIPES, style_name=WriterStylePageKind.STANDARD
)
Styler.apply(doc, header_style, img_style)
Style results.
Getting image from a style
# ... other code
style_obj = HeaderAreaImg.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 header area pattern of a page style.
The result are seen in Fig. 1135 and Fig. 1136.
The PresetPatternKind
class is used to look up the presets of pattern for convenience.
from ooodev.format.writer.modify.page.header.area import Pattern as HeaderStylePattern, PresetPatternKind
# ... other code
pattern_style = HeaderStylePattern.from_preset(
preset=PresetPatternKind.HORIZONTAL_BRICK, style_name=WriterStylePageKind.STANDARD
)
Styler.apply(doc, header_style, pattern_style)
Style results.
Getting pattern from a style
# ... other code
style_obj = HeaderStylePattern.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 header area hatch of a page style.
The result are seen in Fig. 1137 and Fig. 1138.
The PresetHatchKind
class is used to look up the presets of hatch for convenience.
from ooodev.format.writer.modify.page.header.area import Hatch as HeaderStyleHatch, PresetHatchKind
# ... other code
hatch_style = HeaderStyleHatch.from_preset(
preset=PresetHatchKind.RED_45_DEGREES_NEG_TRIPLE, style_name=WriterStylePageKind.STANDARD
)
Styler.apply(doc, header_style, hatch_style)
Style results.
Getting hatch from a style
# ... other code
style_obj = HeaderStyleHatch.from_style(doc=doc, style_name=WriterStylePageKind.STANDARD)
assert style_obj.prop_style_name == str(WriterStylePageKind.STANDARD)