Class Focus

Intro

The Focus class allows for setting foucs of a LibreOffice Window.

For example to focus on the default windows created with ooodev.utils.lo.Lo.load_office().

from ooodev.office.draw import Draw
from ooodev.utils.gui import GUI
from ooodev.utils.lo import Lo

try:
    # only windows
    from odevgui_win.focus import Focus
except ImportError:
    Focus = None

def main() -> int:
    loader = Lo.load_office(Lo.ConnectPipe())

    try:
        doc = Draw.create_draw_doc(loader)
        slide = Draw.get_slide(doc=doc, idx=0)

        GUI.set_visible(is_visible=True, odoc=doc)
        Lo.delay(1_000)
        GUI.zoom(view=GUI.ZoomEnum.ENTIRE_PAGE)

        if Focus:
            Focus.focus_current()

        # do other document processing
    except Exception:
        Lo.close_office()
        raise
    return 0

if __name__ == "__main__":
    SystemExit(main())

Class

class odevgui_win.focus.Focus[source]
classmethod focus(*titles: WindowTitle) Rectangle | None[source]

Set focus on first window that matches.

Parameters:

*titles – Expandable list of ooodev.utils.data_type.window_title.WindowTitle

Returns:

Rectangle representing window if found; Otherwise, None

Return type:

Rectangle

See also

focus_current()

classmethod focus_current() Rectangle | None[source]

Focuses on the current window detected by ooodev.utils.lo.Lo.

Returns:

Rectangle representing window if found; Otherwise, None

Return type:

Rectangle

See also

focus()