0

After running the code , the second placeholder in the template stays empty

import tkinter as tk from tkinter import messagebox from docxtpl import DocxTemplate class BaseTemplate: def __init__(self, template_name, context): self.template_name = template_name self.context = context def render(self): doc = DocxTemplate(self.template_name) doc.render(self.context) return doc class Template1(BaseTemplate): def __init__(self, context): template_name = "template1.docx" super().__init__(template_name, context) class Template2(BaseTemplate): def __init__(self, context): template_name = "template2.docx" super().__init__(template_name, context) def render_document(): # Get user input from tkinter entry widgets title = entry_title.get() content = entry_content.get() # Define contexts for each template context1 = {"title": title, "content": content} context2 = {"title": title, "content": content} # Render documents using inheritance template1 = Template1(context1) r

20th Mar 2024, 7:05 AM
Yacine Becha
Yacine Becha - avatar
1 Respuesta
+ 1
Yacine Becha , Your code is cut off. Save it in the playground and post the link instead. Sololearn doesn't support tkinter, but any interested reader could copy your code to an external IDE to check, assuming they have one. I haven't used tkinter yet, and I don't know the answer to your problem, but just looking at the portion of your code you pasted, I do have a question. Why do you define both Template1 and Template2 child classes when their definitions are otherwise identical?
21st Mar 2024, 11:45 AM
Rain
Rain - avatar