My program creates different widgets depending on the selection from a radio button. Everything works great except I can't seem to clear the old widget if the other radio button is selected. The suggestion here: (https://stackoverflow.com/a/15995920/3924118) isn't working. Here's the relevant code.
From the main program:
root = Tk()
mainframe = ttk.Frame(root, padding="3 3 12 12")
mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
mainframe.columnconfigure(0, weight=1)
mainframe.rowconfigure(0, weight=1)
secondframe = ttk.Frame(mainframe)
secondframe.grid(column=4, row=3)
secondframe.columnconfigure(0, weight=1)
secondframe.columnconfigure(0, weight=1)
And then the function:
def pct_from_duration():
""" Calculate needed pct from target duration"""
tgt_dur_entry = ttk.Entry(mainframe, width=4, textvariable=tgt_dur_inp)
tgt_dur_entry.grid(column=5, row=3, sticky=(W, E))
for widget in secondframe.winfo_children():
widget.destroy()
ttk.Label(secondframe, textvariable=pct_bond_end).grid(column=1, row=1)
ttk.Button(mainframe, text="Calculate", command=calculate).grid(column=5, row=4, sticky=W)
FWIW, I get no error message, it just doesn't actually delete the widgets. This is all python 3.6.