Rewriting our application using classes
Now that we've learned these techniques for using classes in our code, let's apply it to our ABQ Data Entry application. We'll start with a fresh file called data_entry_app.py and add in our import statements, like so:
# data_entry_app.py
from datetime import datetime
from pathlib import Path
import csv
import tkinter as tk
from tkinter import ttk
Now, let's see how we can apply some class-based techniques to rewrite a cleaner version of our application code.
Adding a StringVar to the Text widget
One annoyance we discovered in creating our application was that the Text widget does not allow the use of a StringVar to store its content, requiring us to treat it differently than all our other widgets. There is a good reason for this: the Tkinter Text widget is far more than just a multi-line Entry widget, capable of containing rich text, images, and other things that a lowly StringVar cannot store. That said...