Write Direct Paragraph Area Color Class

Overview

The ooodev.format.writer.direct.para.area.Color class is used to set the paragraph background area color.

Setting the style

General function used to run these examples.

import sys
from ooodev.office.write import Write
from ooodev.utils.color import CommonColor
from ooodev.gui import GUI
from ooodev.loader.lo import Lo
from ooodev.format.writer.direct.para.area import Color as ParaBgColor


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)
        cursor = Write.get_cursor(doc)
        fc = ParaBgColor(CommonColor.YELLOW_GREEN)
        Write.append_para(cursor=cursor, text="Fill Color starts Here", styles=[fc])

        Lo.delay(1_000)

        Lo.close_doc(doc)

    return 0


if __name__ == "__main__":
    sys.exit(main())

Examples

Fill Color a single Paragraph

cursor = Write.get_cursor(doc)
fc = ParaBgColor(CommonColor.YELLOW_GREEN)
Write.append_para(cursor=cursor, text="Fill Color starts Here", styles=[fc])
Paragraph with background color

Fig. 951 Paragraph with background color.

Paragraph area color dialog

Fig. 952 Paragraph area color dialog.

Fill Color Multiple paragraphs

cursor = Write.get_cursor(doc)
fc = ParaBgColor(CommonColor.YELLOW_GREEN)
Write.append_para(cursor=cursor, text="Fill Color starts Here", styles=[fc])
fc = ParaBgColor(CommonColor.LIGHT_BLUE)
Write.append_para(cursor=cursor, text="And today Ends Here", styles=[fc])
Paragraph with background color

Fig. 953 Paragraph with background color.

Apply Fill cursor to Cursor

A Fill Color can be set on the cursor and then it remains until it is removed.

The fill color can be cleared by using ParaStyle.default values.

from ooodev.format.writer.style.para import Para as ParaStyle
# ... other code

cursor = Write.get_cursor(doc)
fc = ParaBgColor(CommonColor.YELLOW_GREEN)
fc.apply(cursor.TextParagraph)
Write.append_para(cursor=cursor, text="Fill Color starts Here")
Write.append_para(cursor=cursor, text="And today Ends Here")
ParaStyle.default.apply(cursor)
Write.append_para(cursor=cursor, text="Nothing to report")
Paragraph style reset

Fig. 954 Paragraph style reset.