Moving the views

Next, we need to create the views.py file. Views are larger GUI components, like our DataRecordForm class. Currently it's our only view, but we'll be creating more views in later chapters, and they'll be added here.

Open the views.py file and copy in the DataRecordForm class, then go back to the top to deal with the module imports. Again, we'll need tkinter and ttk, and our file saving logic relies on datetime for the filename.

Add them to the top of the file as follows:

import tkinter as tk
from tkinter import ttk
from datetime import datetime

We aren't done, though; our actual widgets aren't here and we'll need to import them. Since we're going to be doing a lot of importing of objects between our files, let's pause for ...

Get Python GUI Programming with Tkinter now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.