python - Tkinter Forgetting Widgets made inside another function -
i want know how forget widget made instead function? code quiet messy.
def page2(cur1): label2 = label(root, text="how convert?") entry1 = entry(root) buttonsubmit = button(root, text="submit", command=lambda: get_entry(entry1, cur1)) label2.grid(row=1, columnspan=5) entry1.grid(row=2, sticky="w") buttonsubmit.grid(row=2, column=1)
i want able forget these widgets function so:
def forget(): label2.grid_forget() entry1.grid_forget()
thanks in advance.
if find needing lot, should re-structure program using classes.
you can move creation of widgets global scope , grid/forget them whenever needed.
#create widgets in global scope can reach them in function label2 = label(root, text="how convert?") entry1 = entry(root) def page2(cur1): buttonsubmit = button(root, text="submit", command=lambda: get_entry(entry1, cur1)) label2.grid(row=1, columnspan=5) entry1.grid(row=2, sticky="w") buttonsubmit.grid(row=2, column=1) def forget(): label2.grid_forget() entry1.grid_forget()
Comments
Post a Comment