53 lines
1.5 KiB
Python
Executable file
53 lines
1.5 KiB
Python
Executable file
#!/usr/bin/python3
|
|
|
|
from docx import Document
|
|
from docx.shared import Inches
|
|
|
|
from pprint import pprint
|
|
|
|
document = Document('Thesis-Fragebogen.docx')
|
|
|
|
# for par in document.paragraphs:
|
|
# print(par.text)
|
|
# print("---style||" + par.style.name)
|
|
# print("############")
|
|
# for tab in document.tables:
|
|
# print("...style||" + tab.style.name)
|
|
# pprint(dir(tab.style))
|
|
# pp = par.part
|
|
# pprint(dir(pp))
|
|
# for r in par.runs:
|
|
# pprint(r.text)
|
|
|
|
from docx.enum.style import WD_STYLE_TYPE
|
|
|
|
styles = document.styles
|
|
paragraph_styles = [
|
|
s for s in styles if s.type == WD_STYLE_TYPE.PARAGRAPH
|
|
]
|
|
for style in paragraph_styles:
|
|
print(style.name)
|
|
|
|
document.add_paragraph('Fragebogen (TODO Import)', style='Überschrift-Anhang 1')
|
|
document.add_paragraph('Fragen zur Verzwergung', style='Überschrift-Anhang 2')
|
|
document.add_paragraph('Hoffnungslosigkeit', style='Überschrift-Anhang 3')
|
|
|
|
document.add_paragraph('Ich könnte mir jeden Tag die Kugel geben', style='Fragebogen-Item')
|
|
|
|
table = document.add_table(rows=3, cols=6)
|
|
|
|
labels = ['niemals','vielleicht','manchmal','immer', 'sowieso']
|
|
|
|
for r in table.rows:
|
|
for c in r.cells:
|
|
c.paragraphs[0].style = 'Frabebogen-Wert'
|
|
|
|
for c in range(1,6):
|
|
table.cell(0,c).paragraphs[0].text = labels[c-1]
|
|
table.cell(1,c).paragraphs[0].text = '□'
|
|
table.cell(2,c).paragraphs[0].text = '□'
|
|
|
|
table.cell(1,0).paragraphs[0].text = "IST"
|
|
table.cell(2,0).paragraphs[0].text = "SOLL"
|
|
|
|
#document.save('Mist.docx')
|