我在下面有一段代码,我有一个必须清空列表和文本框的按钮(prnt_button),但不幸的是,它只清空了文本框,我怎么能更改代码,以便按钮也清空列表?
# This is in a for loop, you press a button to go to the next step,
# every step you comes along the next piece of code:
if k == 3:
doc = DocxTemplate("template.docx")
context = { # Fill in some template variables
}
doc.render(context)
docin = f"{numlist[0]}_{numlist[1]}_{numlist[2]}"
locdoc = f'{text}\\' + docin
doc.save(f"{locdoc}.docx")
prntng_l.append(docin)
# and more things, which work fine.
k = 1
else:
k = k + 1
maken_files_not_printed = Text(mult_prnt_frame1, width=column_width, height=10, state='disabled')
maken_files_not_printed.grid(row=1, column=0)
def print_all_files_in_list(prntng_l):
maken_files_not_printed.config(state="normal")
maken_files_not_printed.delete(1.0, 'end')
maken_files_not_printed.config(state="disabled")
prnt_button.config(text="Print: 0", state='disabled')
prntng_l = []
return (prntng_l)
prnt_button = Button(mult_prnt_frame1, text="Print 0", width=column_width + 2, height=1,
command=lambda: print_all_files_in_list(prntng_l), state='normal')
prnt_button.grid(row=0, column=0)
maken_files_not_printed.config(state='normal')
maken_files_not_printed.delete(1.0, 'end')
for q in range(len(prntng_l)):
prnt_button.config(text="Print: " + str(q + 1), state="normal")
maken_files_not_printed.insert('end', "Naam bestand " + str(q + 1) + ":\n" + prntng_l[q] + "\n")
maken_files_not_printed.config(state='disabled')
有人可以帮我吗?提前致谢。