lpod.frame

class lpod.frame.odf_frame(native_element)

Bases: lpod.element.odf_element

get_formatted_text(context)
get_frame_anchor_type()

Get how the frame is attached to its environment.

Return: ‘page’, ‘frame’, ‘paragraph’, ‘char’ or ‘as-char’

get_frame_name()
get_frame_page_number()

Get the number of the page where the frame is attached when the anchor type is ‘page’.

Return: int

get_frame_position()

Get the position of the frame relative to its anchor point.

Position is a (left, top) tuple with items including the unit, e.g. (‘10cm’, ‘15cm’).

Return: (str, str)

get_frame_size()

Get the size of the frame.

Size is a (width, height) tuple with items including the unit, e.g. (‘10cm’, ‘15cm’).

Return: (str, str)

set_frame_anchor_type(anchor_type, page_number=None)

Set how the frame is attached to its environment.

When the type is ‘page’, you can give the number of the page where to attach.

Arguments:

anchor_type – ‘page’, ‘frame’, ‘paragraph’, ‘char’ or ‘as-char’

page_number – int (when anchor_type == ‘page’)

set_frame_name(name)
set_frame_page_number(page_number)

Set the number of the page where the frame is attached when the anchor type is ‘page’, or None to delete it

Arguments:

page_number – int or None
set_frame_position(position)

Set the position of the frame relative to its anchor point.

Position is a (left, top) tuple with items including the unit, e.g. (‘10cm’, ‘15cm’).

Arguments:

position – (str, str)
set_frame_size(size)

Set the size of the frame.

Size is a (width, height) tuple with items including the unit, e.g. (‘10cm’, ‘15cm’). The dimensions can be None.

Arguments:

size – (str, str)
lpod.frame.odf_create_frame(name=None, size=('1cm', '1cm'), anchor_type='paragraph', page_number=None, position=None, style=None)

Create a frame element of the given size. If positioned by page, give the page number and the x, y position.

Size is a (width, height) tuple and position is a (left, top) tuple; items are strings including the unit, e.g. (‘10cm’, ‘15cm’).

Frames are not useful by themselves. You should consider calling odf_create_image_frame or odf_create_text_frame directly.

Arguments:

name – unicode

size – (str, str)

anchor_type – ‘page’, ‘frame’, ‘paragraph’ (default), ‘char’
or ‘as-char’

page_number – int (when anchor_type == ‘page’)

position – (str, str)

style – unicode

Return: odf_element

lpod.frame.odf_create_image_frame(uri, text=None, size=('1cm', '1cm'), anchor_type='paragraph', page_number=None, position=None, style=None)

Create a ready-to-use image, since it must be embedded in a frame.

The optionnal text will appear above the image.

Size is a (width, height) tuple and position is a (left, top) tuple; items are strings including the unit, e.g. (‘21cm’, ‘29.7cm’).

Arguments:

uri – str

text – unicode

size – (str, str)

anchor_type – ‘page’, ‘frame’, ‘paragraph’, ‘char’ or ‘as-char’

page_number – int (when anchor_type == ‘page’)

position – (str, str)

style – unicode

Return: odf_element

lpod.frame.odf_create_text_frame(text_or_element, size=('1cm', '1cm'), anchor_type='paragraph', page_number=None, position=None, style=None, text_style=None)

Create a ready-to-use text box, since it must be embedded in a frame.

Size is a (width, height) tuple and position is a (left, top) tuple; items are strings including the unit, e.g. (‘21cm’, ‘29.7cm’).

Arguments:

text_or_element – unicode or odf_element

size – (str, str)

anchor_type – ‘page’, ‘frame’, ‘paragraph’, ‘char’ or ‘as-char’

page_number – int (when anchor_type == ‘page’)

position – (str, str)

style – unicode

text_style – unicode

Return: odf_element