Skip to Main Content
Tkinter GUI Application Development Blueprints
book

Tkinter GUI Application Development Blueprints

by Bhaskar Chaudhary
November 2015
Beginner to intermediate content levelBeginner to intermediate
340 pages
7h 29m
English
Packt Publishing
Content preview from Tkinter GUI Application Development Blueprints

Building a screen saver

We will start by building a screen saver. The program 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

Let's create a class to generate balls with random attributes. Accordingly, we define a new class named RandomBall. 7.01_screensaver.py:

class RandomBall:

    def __init__(self, canvas):
        self.canvas = canvas
        self.screen_width = canvas.winfo_screenwidth()
        self.screen_height = canvas.winfo_screenheight()
        self.create_ball()
        
    def create_ball(self): self.generate_random_attributes() self.create_oval() def generate_random_attributes(self): ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Python Application Development

Learning Python Application Development

Ninad Sathaye

Publisher Resources

ISBN: 9781785889738Supplemental Content