Boston Python Workshop/Saturday/ColorWall

From OpenHatch wiki
Jump to navigation Jump to search

Program graphical effects for a ColorWall using the Tkinter GUI toolkit. See the ColorWall in action here.


See the Friday setup instructions.


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

Suggested exercises[edit]

  • Find and change the colors used in the Checkerboards effect, and re-run the effect:
    python Checkerboards

    Then change the line

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


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

    re-run the effect, and see what changed.

  • Find and change the color of the columns in the Matrix effect, and re-run the effect:
    python Matrix

    Each column that we see on the wall corresponds to a Column object. Add some randomness to the color used by each column (the variable whose value you changed above) using the random.random function, re-run the effect, and see what happens.

  • Walk through Twinkle. Find explanations of the random.randint and random.uniform functions in the online documentation at 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 Twinkle
  • Write your own effects!

Some Useful Links[edit]

If you choose to use HSV colors you define instead of the dictionary, you may find some of the following useful:

« Back to the Saturday project page