Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Python Game Programming By Example

You're reading from   Python Game Programming By Example A pragmatic guide for developing your own games with Python

Arrow left icon
Product type Paperback
Published in Sep 2015
Publisher
ISBN-13 9781785281532
Length 230 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Toc

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...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime