Creating the application file

Finally, let's create our controller class, Application, by following these steps:

  1. Open the application.py file and copy in the Application class definition from the script.

 

  1. The first thing we'll fix is our imports. At the top of the file, add the following code:
import tkinter as tk
from tkinter import ttk
from datetime import datetime
from . import views as v
from . import models as m

We need tkinter and ttk, of course, and datetime to define our filename. Although we only need one class each from views and models, we're going to keep them in their own namespaces anyway. It's likely we're going to have many more views as the application expands, and possibly more models.

  1. We need to update the call to ...

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.