Boston Python workshop/Saturday/ColorWall

Project
Program graphical effects for a ColorWall using the Tkinter GUI toolkit.

Goals

 * Have fun experiment with and creating graphical effects.
 * Practice using functions and classes.
 * Get experience with graphics programming using the Tkinter GUI toolkit.

Download and un-archive the ColorWall project skeleton code

 * http://web.mit.edu/jesstess/www/BostonPythonWorkshop6/ColorWall.zip

Un-archiving will produce a  folder containing several Python files, including: run.py, effects.py, and advanced_effects.py.

Test your setup
From a command prompt, navigate to the  directory and run

python run.py -a

You should see a window pop up and start cycling through colorful effects. If you don't, let a staff member know so you can debug this together.

1. Learn about HSV values
Run the ColorWall effects again with

python run.py -a

The names of the effects are printed to the terminal as they are run. Pay particular attention to the first 4 effects:
 * SolidColorTest
 * HueTest
 * SaturationTest
 * ValueTest

What are the differences between these tests? Given these difference and how they are expressed visually, how does varying hue, saturation, or value change a color?

2. Examine and the interface its subclasses provide
All of the effects inherit from the  class. Examine this class and its  and   methods.

Suggested exercises
  Find and change the colors used in the  effect, and re-run the effect:

python run.py Checkerboards

Then change the line

if (x + y + i) % 2 == 0:

to

if (x + y + i) % 3 == 0:

re-run the effect, and see what changed.   Find and change the color of the columns in the  effect, and re-run the effect:

python run.py Matrix

Each column that we see on the wall corresponds to a  object. Add some randomness to the color used by each column (the variable whose value you changed above) using the  function, re-run the effect, and see what happens.   Walk through. Find explanations of the  and   functions in the online documentation at

http://docs.python.org/library/random.html.

Experiment with these functions at a Python prompt:

import random random.randint(0, 1) random.randint(0, 5) random.uniform(-1, 1)

Then experiment with the numbers that make up the hue and re-run the effect:

python run.py Twinkle   Write your own effects!  

Some Useful Links
If you choose to use HSV colors you define instead of the dictionary, you may find some of the following useful:
 * A graphical HSV color picking website
 * HSV on Wikipedia
 * Python random library
 * Python time library

&laquo; Back to the Saturday project page