Automating input
Preventing users from entering bad data is one way to help users enter better data; another approach is to automate. Using our understanding of how the forms are likely to be filled out, we can insert values that are very likely to be correct for certain fields.
Remember from Chapter 2, Designing GUI Applications with Tkinter, that the forms are nearly always recorded the same day that they're filled out, and that they're filled out one at a time from Plot
1 to Plot
20 in order. Also remember that the Date
, Lab
, and Technician
values remain the same for each form which is filled in. Let's automate this for our users.
Inserting a date
Inserting the current date is an easy place to start. The place to do this is in the DataRecordForm.reset()
method, which sets up the form for entering a new record.
Update that method as follows:
def reset(self): """Resets the form entries""" # clear all values for widget in self.inputs.values(): widget.set...