The Python Programming class that I taught in the spring 2009 semester studied how to program graphical user interfaces. The final project of the class was to design an object oriented black jack card game with a graphical user interface. Described on the following pages is my implementation.
This class was taught as a lower level CMST elective. Thus it was an introductory programming class. The text book that we used was: Python Programming: An Introduction To Computer Science, by John Zelle. This book uses graphics programming as a means to introduce object oriented programming. Thus, the book provides an object oriented module called graphics, which has facilities for displaying basic graphics primitives such as circles, squares, lines and also has a method to catch mouse click events returning the x, y coordinates of where the mouse was clicked. Based on this module, a basic button class is developed. This graphics module is an object oriented wrapper around Python’s standard tkinter module. The graphics module is in one sense an improvement on tkinter because it is object oriented, but much of the functionality of tkinter is removed, including the main loop that generates function backs based on event, such as mouse clicks and keyboard data entry. Thus, the first order of business to seriously use this module was to write a class to provide event driven method call backs. I wrote this class and used it to teach the basic concepts of asynchronous event driven programming. The journey from having a very basics graphics module to having an event driven programming framework to a final working black jack game was excellent from a teaching perspective. From talking to the students, I’m quite certain that a number of students advanced tremendously as programmers from this assignment. However, from just a pure programming perspective, the graphics framework that we used was fairly poor. Starting with a mature graphics framework, such as wxPython, as I did with the Multi-party Chat Client and Server and Graphical Weather Forecast Viewer applications is a much preferred way to write a graphical application. However, my prime objective here was not to write a black jack application, but to teach object oriented programming, and that most certainly was accomplished.
Contents: