Tkinter Invoice Generator System

76 Views Asked by At
 Exception in Tkinter callback
 Traceback (most recent call last):
 File "tkinter\__init_\_.py", line 1921, in __call__
 File "Bill.py", line 62, in generate
 File "docxtpl\\template.py", line 359, in render
 File "docxtpl\\template.py", line 52, in render_init
 File "docxtpl\\template.py", line 48, in init_docx
 File "docx\\api.py", line 23, in Document
 File "docx\\opc\\package.py", line 116, in open
 File "docx\\opc\\pkgreader.py", line 22, in from_file
 File "docx\\opc\\phys_pkg.py", line 21, in __new__
 docx.opc.exceptions.PackageNotFoundError: Package not found at 'Template/invoice_template.docx
PATH STRUCTURE:
Bill System:
\__Template
   \__invoice_template.docx
\__Bill.py
# Get the absolute path to the 'Template' folder
template_folder = os.path.abspath('Template')

# Construct the full path to the template file
template_file_path = os.path.join(template_folder, 'invoice_template.docx')

def generate():
    doc = DocxTemplate(template_file_path)
    name = namebox.get()
    place = placebox.get()
    phone = phbox.get()
    subtotal = sum(item[3] for item in invoice_list) 
    salestax = 0.1
    total = subtotal*(1-salestax)
    
    doc.render({"name":name, 
            "place":place,
            "phone":phone,
            "invoice_list": invoice_list,
            "subtotal":subtotal,
            "salestax":str(salestax*100)+"%",
            "total":total})
    
    doc_name = name + datetime.datetime.now().strftime("%Y-%m-%d-%H%M%S") + ".docx"
    doc.save(doc_name)
  • logs

Here I'm Building Invoice-Generator using python Tkinter lib. The program run's successfully in .py script file but while it convert it into .exe file it throws me this error. I have tried abs path, relative path but there is no result. So, I'm stuck with this problem let somebody come step to solve this.

0

There are 0 best solutions below