Building the GUI application
The Checkers
module will contain all of the code required for the GUI application. This module depends on wxPython as well as Python's standard threading
module to allow us to put all of the intensive computer vision work onto a background thread. Moreover, we will rely on our CheckersModel
module for the capturing and analysis of images, and our WxUtils module for its image conversion utility function. Here are the relevant import
statements:
import threading import wx import CheckersModel import WxUtils
Our application class, Checkers
, is a subclass of wx.Frame
, which represents a normal window (not a dialog). We initialize it with an instance of CheckersModel
, and a window title (Checkers by default). Here are the declarations of the class and the __init__
method:
class Checkers(wx.Frame): def __init__(self, checkersModel, title='Checkers'):
We will also store CheckersModel
in a member variable, like this:
self._checkersModel = checkersModel
The implementation...