Write Modify Page Footer Transparency
The ooodev.format.writer.modify.page.footer.transparency.Transparency
and ooodev.format.writer.modify.page.footer.transparency.Gradient
classes are used to modify the Area style values seen in Fig. 1168 of a Page style.
Default Page Style Dialog
Setup
General function used to run these examples.
from ooodev.format.writer.modify.page.footer import Footer, WriterStylePageKind
from ooodev.format.writer.modify.page.footer.transparency import (
Transparency,
Gradient,
IntensityRange,
GradientStyle,
)
from ooodev.format.writer.modify.page.footer.area import Color as HeaderAreaColor
from ooodev.format import Styler
from ooodev.utils.color import StandardColor
from ooodev.office.write import Write
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,
)
page_footer_style_kind = WriterStylePageKind.STANDARD
color_style = HeaderAreaColor(color=StandardColor.RED, style_name=page_footer_style_kind)
transparency_style = Transparency(value=85, style_name=page_footer_style_kind)
Styler.apply(doc, footer_style, color_style, transparency_style)
style_obj = Transparency.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())
Transparency
The Transparency
class is used to modify the transparency of a page footer style.
The result are seen in Fig. 1169 and Fig. 1170.
Setting Transparency
In this example we will apply a transparency to the page footer style background color.
The transparency needs to be applied after the page footer style color as the transparency is applied to the color.
This means the order Styler.apply(doc, footer_style, color_style, transparency_style)
is important.
The transparency is set to 85% in this example.
# ... other code
page_footer_style_kind = WriterStylePageKind.STANDARD
color_style = HeaderAreaColor(color=StandardColor.RED, style_name=page_footer_style_kind)
transparency_style = Transparency(value=85, style_name=page_footer_style_kind)
Styler.apply(doc, footer_style, color_style, transparency_style)
Style results.
Getting transparency from a style
# ... other code
style_obj = Transparency.from_style(doc=doc, style_name=WriterStylePageKind.STANDARD)
assert style_obj.prop_style_name == str(WriterStylePageKind.STANDARD)
Transparency Gradient
Setting Transparency Gradient
The Gradient
class is used to modify the area gradient of a page footer style.
The result are seen in Fig. 1171 and Fig. 1172.
In this example we will apply a transparency to the page footer style background color.
The transparency needs to be applied after the page footer style color as the transparency is applied to the color.
This means the order Styler.apply(doc, footer_style, color_style, footer_gradient_style)
is important.
# ... other code
page_footer_style_kind = WriterStylePageKind.STANDARD
color_style = HeaderAreaColor(color=StandardColor.GREEN_DARK1, style_name=page_footer_style_kind)
footer_gradient_style = Gradient(
style=GradientStyle.LINEAR,
angle=45,
border=22,
grad_intensity=IntensityRange(0, 100),
style_name=page_footer_style_kind,
)
Styler.apply(doc, footer_style, color_style, footer_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)