from pathlib import Path
from docxtpl import DocxTemplate
import datetime
import PySimpleGUI as sg
document_path = Path(__file__).parent / "Simple_file_path.docx"
doc = DocxTemplate(document_path)
today = datetime.datetime.today()
layout = [[sg.Text("Assembly"), sg.Input(key="ASSEMBLY")],
[sg.Text("ArtikelNr"), sg.Input(key="ARTIKELNR")],
[sg.Text("Customer"), sg.Input(key="CUSTOMER")],
[sg.Text("Reference"), sg.Input(key="REFERENCE")],
[sg.Text("OrderNr"), sg.Input(key="ORDERNR")],
[sg.Text("elspec serial no."), sg.Input(key="ELSPECSERIALNR")],
[sg.Text("umgebungsTemp"), sg.Input(key="UMGEBUNGSTMP")],
[sg.Text("validator name"), sg.Input(key="VALIDATORNAME")],
[sg.Button("Vorlage erstellen"), sg.Exit()], ]
window = sg.Window("Druck Vorlage ", layout, element_justification="right")
while True:
event, values = window.read()
if event == sg.WIN_CLOSED or event == "Exit":
break
if event == "Vorlage erstellen":
values["TODAY"] = today.strftime("%d.%m-%Y")
doc.render(values)
doc.save(Path(__file__).parent / "generated_wordTemp.docx")
window.close()
How to add (.PNG) file in (.docx) file
-
- User
- Beiträge: 18
- Registriert: Dienstag 22. März 2022, 14:40
Hallo everyone. i wanna add a .png file in the created word document, i need your Suggestion please.
"When I got the music, I got a place to go" [Rancid, 1993]