Building a screen saver

We will start by building a screen saver for our desktop. The screen saver will consist of several random-colored and random-sized balls bouncing all over the screen at random velocity, as shown in the following screenshot:

Building a screen saver

Engage Thrusters

Carry out the following steps to create the screen saver:

  1. Let's create a class to generate balls with random attributes. Accordingly, we define a new class named RandomBall to achieve this (refer to the 7.01 Python file, available in the code bundle):
    from random import randint class RandomBall: def __init__(self, canvas, scrnwidth, scrnheight): self.canvas = canvas self.xpos ...

Get Tkinter GUI Application Development HOTSHOT now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.