lpod.frame

class lpod.frame.odf_frame(native_element, cache=None)

Bases: lpod.element.odf_element

get_anchor_type()

Get how the frame is attached to its environment.

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

get_formatted_text(context)
get_id()
get_image()
get_layer()
get_name()
get_page_number()

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

Return: int

get_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_presentation_class()
get_presentation_style()
get_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)

get_style()
get_text_box()
get_text_content()
get_z_index()
set_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_id(frame_id)
set_image(url_or_element, text=None)
set_layer(layer)
set_name(name)
set_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_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_presentation_class(presentation_class)
set_presentation_style(name)
set_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)
set_style(name)
set_text_box(text_or_element=None, text_style=None)
set_text_content(text_or_element)
set_z_index(z_index)
lpod.frame.odf_create_frame(name=None, draw_id=None, style=None, position=None, size=('1cm', '1cm'), z_index=0, presentation_class=None, anchor_type=None, page_number=None, layer=None, presentation_style=None)

Create a frame element of the given size. Position is relative to the context the frame is inserted in. 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

draw_id – unicode

style – unicode

position – (str, str)

size – (str, str)

z_index – int (default 0)

presentation_class – unicode

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

page_number (anchor_type=’page’) – int

layer – unicode

presentation_style – unicode

Return: odf_frame

lpod.frame.odf_create_frame_position_style(name=u'FramePosition', horizontal_pos='from-left', vertical_pos='from-top', horizontal_rel='paragraph', vertical_rel='paragraph')

Helper style for positioning frames in desktop applications that need it.

Default arguments should be enough.

Use the return value as the frame style or build a new graphic style with this style as the parent.

lpod.frame.odf_create_image_frame(url, text=None, name=None, draw_id=None, style=None, position=None, size=('1cm', '1cm'), z_index=0, presentation_class=None, anchor_type=None, page_number=None, layer=None, presentation_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:

url – str

text – unicode

name – unicode

draw_id – unicode

style – unicode

position – (str, str)

size – (str, str)

z_index – int (default 0)

presentation_class – unicode

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

page_number (anchor_type=’page’) – int

layer – unicode

presentation_style – unicode

Return: odf_frame

lpod.frame.odf_create_text_frame(text_or_element=None, text_style=None, name=None, draw_id=None, style=None, position=None, size=('1cm', '1cm'), z_index=0, presentation_class=None, anchor_type=None, page_number=None, layer=None, presentation_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

text_style – unicode

name – unicode

draw_id – unicode

style – unicode

position – (str, str)

size – (str, str)

z_index – int (default 0)

presentation_class – unicode

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

page_number (anchor_type=’page’) – int

layer – unicode

presentation_style – unicode

Return: odf_frame

Previous topic

lpod.experimental

Next topic

lpod.future

This Page