#!/usr/bin/env python
import os

# Uncommented parts are explained in : create_a_basic_document_with_a_list.py

from odfdo import Document, List, ListItem

# Create the document
my_document = Document('text')
body = my_document.body

# Adding List
my_list = List(['Arthur', 'Ford', 'Trillian'])
item = ListItem('Marvin')
my_list.append_item(item)
body.append(my_list)

# Adding Sublist¶
# A sublist is simply a list as an item of another list:
item.append(List(['Paranoid Android', 'older than the universe']))

# See the result:
print(my_document.get_formatted_text())
# - Arthur
# - Ford
# - Trillian
# - Marvin
#   - Paranoid Android
#   - older than the universe

# Inserting List Item
from odfdo import Document, List

document = Document("text")
body = document.body

my_list = List(["chocolat", "café"])

# In case your forgot to insert an important item:
my_list.insert_item("Chicorée", position=1)

# Or you can insert it before another item:
cafe = my_list.get_item(content="café")
my_list.insert_item("Chicorée", before=cafe)

# Or after:
my_list.insert_item("Chicorée", after=cafe)
示例#3
0
#!/usr/bin/env python

import os

# Uncommented parts are explained in : create_a_basic_text_document.py

from odfdo import Document, List, ListItem

# Create the document
my_document = Document("text")
body = my_document.body

# Adding List
my_list = List(["Arthur", "Ford", "Trillian"])
# The list accepts a Python list of strings and list items.

# The list can be written even though we will modify it afterwards:
body.append(my_list)

# Adding more List Item to the list
item = ListItem("Marvin")
my_list.append_item(item)

if not os.path.exists("test_output"):
    os.mkdir("test_output")

output = os.path.join("test_output", "my_document_with_list.odt")

# And finally save the document.
my_document.save(target=output, pretty=True)
from odfdo import Document

document = Document('text')
body = document.body

# Lists are a dedicated object
from odfdo import List
my_list = List(['chocolat', 'café'])

# The list factory accepts a Python list of strings and list items.
#
# The list can be written even though we will modify it afterwards:

body.append(my_list)
示例#5
0
#!/usr/bin/env python

import os

# Uncommented parts are explained in : create_a_basic_text_document.py

from odfdo import Document, List, ListItem

# Create the document
my_document = Document('text')
body = my_document.body

# Adding List
my_list = List(['Arthur', 'Ford', 'Trillian'])
# The list accepts a Python list of strings and list items.

# The list can be written even though we will modify it afterwards:
body.append(my_list)

# Adding more List Item to the list
item = ListItem('Marvin')
my_list.append_item(item)

if not os.path.exists('test_output'):
    os.mkdir('test_output')

output = os.path.join('test_output', 'my_document_with_list.odt')

# And finally save the document.
my_document.save(target=output, pretty=True)
示例#6
0
tax_rate = .196

if __name__ == "__main__":
    commercial = Document('text')
    body = commercial.body
    catalog = make_catalog()

    title1 = Header(1, "Basic commercial document")
    body.append(title1)
    title11 = Header(2, "Available products")
    body.append(title11)
    paragraph = Paragraph("Here the list:")
    body.append(paragraph)

    # List of products in a list :
    product_list = List()
    body.append(product_list)
    for product in catalog:
        item = ListItem("%-10s, price: %.2f €" % (product.name, product.price))
        product_list.append(item)

    title12 = Header(2, "Your command")
    body.append(title12)

    command = {0: 1, 1: 12, 2: 3, 4: 5}

    # A table in the text document :
    table = Table("Table")
    body.append(table)
    row = Row()
    row.set_values(["Product", "Price", "Quantity", "Amount"])
from odfdo import Document, List, ListItem

document = Document("text")
body = document.body

my_list = List(["chocolat", "café"])
body.append(my_list)

item = ListItem("thé")
my_list.append(item)

# A sublist is simply a list as an item of another list

item.append(List(["thé vert", "thé rouge"]))

print(body.serialize(True))
from odfdo import Document, List, ListItem

document = Document('text')
body = document.body

my_list = List(['chocolat', 'café'])
body.append(my_list)

item = ListItem("thé")
my_list.append(item)

# A sublist is simply a list as an item of another list

item.append(List(["thé vert", "thé rouge"]))

print(body.serialize(True))
示例#9
0
#!/usr/bin/env python
import os

# Uncommented parts are explained in : create_a_basic_document_with_a_list.py

from odfdo import Document, List, ListItem

# Create the document
my_document = Document("text")
body = my_document.body

# Adding List
my_list = List(["Arthur", "Ford", "Trillian"])
item = ListItem("Marvin")
my_list.append_item(item)
body.append(my_list)

# Adding Sublist¶
# A sublist is simply a list as an item of another list:
item.append(List(["Paranoid Android", "older than the universe"]))

# See the result:
print(my_document.get_formatted_text())
# - Arthur
# - Ford
# - Trillian
# - Marvin
#   - Paranoid Android
#   - older than the universe

# Inserting List Item