from docx import Document
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.shared import Pt
from docx.shared import Length
from docx.shared import RGBColor
from docx.enum.style import WD_STYLE

#document = Document()

document = Document('verif_plan_template.docx')

document.add_heading('Document Title', 0)

# define style
#styles = document.styles
#style = styles[WD_STYLE.BODY_TEXT]

p = document.add_paragraph('A plain paragraph having some ')
# insére un espace entre le heading et le paragraphe
p.paragraph_format.space_before = Pt(78)
p.add_run('bold').bold = True
p.add_run(' and some ')
p.add_run('italic.').italic = True
p.add_run(" and some fdf lkjdfksqjfk lsgjsdkgskg fgqgkjqglkqsj  fglkjglkqjgjfg lkjgkqlgjqgj  ")
p.alignment = WD_ALIGN_PARAGRAPH.JUSTIFY


p = document.add_paragraph('Suite du programme A plain paragraph having some ')
p.add_run('bold').bold = True
p.add_run(' and some ')
p.add_run('italic.').italic = True
p.add_run(" and some fdf lkjdfksqjfk lsgjsdkgskg fgqgkjqglkqsj  fglkjglkqjgjfg lkjgkqlgjqgj  ")
p.alignment = WD_ALIGN_PARAGRAPH.JUSTIFY

p.paragraph_format.space_before = Pt(38)



p = document.add_paragraph('')
p.add_run('salit').underline = True
p.add_run('pipotron').bold = True


#style = document.styles['Normal']
#font = style.font
#font.name = 'Arial'
#font.size = Pt(24)
#paragraph.style = document.styles['Normal']

run = document.add_paragraph().add_run()
style = document.styles['Normal']
font = style.font
# fixe la couleur de la fonte
font.color.rgb = RGBColor(0x42, 0x24, 0xE9)
font.name = 'Arial'
font.size = Pt(25)
document.add_paragraph('Some text').add_run()


# OK
p = document.add_paragraph()
runner = p.add_run("word")
runner.bold = True
runner.italic = True
runner.underline = True

document.add_paragraph("blabla", style="ListNumber")
document.add_paragraph("blabla", style="ListNumber2")
document.add_paragraph("blabla", style="ListNumber3")
document.add_paragraph("blabla", style="ListNumber")




# Add a list
p = document.add_paragraph(style = 'ListParagraph', text = "1.")
p = document.add_paragraph(style = 'ListParagraph', text = "2.")
p = document.add_paragraph(style = 'ListParagraph', text = "3.")
p = document.add_paragraph(style = 'ListParagraph', text = "4.")
p = document.add_paragraph(style = 'ListParagraph', text = "5.")
p = document.add_paragraph(style = 'ListParagraph', text = "6.")


#p = document.add_paragraph(style = 'ListContinue', text = "1.")
#p = document.add_paragraph(style = 'ListContinue1', text = "2.")
#p = document.add_paragraph(style = 'ListContinue2', text = "3.")
#p = document.add_paragraph(style = 'ListContinue3', text = "4.")

p = document.add_paragraph(style = 'List', text = "1.")
p = document.add_paragraph(style = 'List', text = "2.")
p = document.add_paragraph(style = 'List', text = "3.")
p = document.add_paragraph(style = 'List', text = "4.")
p = document.add_paragraph(style = 'List', text = "5.")
p = document.add_paragraph(style = 'List', text = "6.")

#
#p0 = d.add_paragraph('Item 1', style='List Bullet')
#list_number(d, p0, level=0, num=False)
#p1 = d.add_paragraph('Item A' , style='List Bullet 2')
#list_number(d, p1, p0, level=1)
#p2 = d.add_paragraph('Item 2', style='List Bullet')
#list_number(d, p2, p1, level=0)
#p3 = d.add_paragraph('Item B', style='List Bullet 2')
#list_number(d, p3, p2, level=1)



document.add_heading('Heading, level 1', level=1)
document.add_paragraph('Intense quote', style='IntenseQuote')

document.add_paragraph(
        'first item in unordered list', style='ListBullet'
)
document.add_paragraph(
        'first item in ordered list', style='ListNumber'
    )

# add page
document.add_page_break()

document.save('toto.docx')
