コード例 #1
0
ファイル: frame.py プロジェクト: nctan/quneiform
def 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
    """
    frame = odf_create_frame(size=size, anchor_type=anchor_type,
            page_number=page_number, position=position, style=style)
    image = odf_create_image(uri)
    if text:
        image.set_text_content(text)
    frame.append(image)
    return frame
コード例 #2
0
ファイル: frame.py プロジェクト: Agicia/lpod-python
 def set_image(self, url_or_element, text=None):
     image = self.get_image()
     if image is None:
         if isinstance(url_or_element, odf_element):
             image = url_or_element
             self.append(image)
         else:
             image = odf_create_image(url_or_element)
             self.append(image)
     else:
         if isinstance(url_or_element, odf_element):
             image.delete()
             image = url_or_element
             self.append(image)
         else:
             image.set_url(url_or_element)
     return image
コード例 #3
0
ファイル: frame.py プロジェクト: Agicia/lpod-python
 def set_image(self, url_or_element, text=None):
     image = self.get_image()
     if image is None:
         if isinstance(url_or_element, odf_element):
             image = url_or_element
             self.append(image)
         else:
             image = odf_create_image(url_or_element)
             self.append(image)
     else:
         if isinstance(url_or_element, odf_element):
             image.delete()
             image = url_or_element
             self.append(image)
         else:
             image.set_url(url_or_element)
     return image
コード例 #4
0
def 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
    """
    frame = odf_create_frame(size=size,
                             anchor_type=anchor_type,
                             page_number=page_number,
                             position=position,
                             style=style)
    image = odf_create_image(uri)
    if text:
        image.set_text_content(text)
    frame.append(image)
    return frame