We're almost done with our form class, but there's one more method needed. After each save of the form, we're going to need to reset it to empty fields; so, let's add a method to do that by performing the following steps:
- Add this method to the end of the form class:
def reset(self): for widget in self.inputs.values(): widget.set('')
- As with our get() method, we're iterating through the input dictionary and setting each widget to an empty value.
- To make sure our application behaves consistently, we should call reset() immediately after the application loads, clearing out any Tk defaults that we might not want.
- Back up to the last line of __init__() and add the following code line:
self.reset()