O'Reilly logo

Tkinter GUI Application Development Blueprints - Second Edition by Bhaskar Chaudhary

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Setting up a broad GUI structure

Let's now set up the broad GUI elements of our program. We will create a PaintApplication class in 6.01.py. Since we want to draw the menu using our framework, we import the framework into our file and inherit from the Framework class as follows:

import frameworkclass PaintApplication(framework.Framework):    def __init__(self, root):    super().__init__(root)    self.create_gui()

The __init__ method calls another method, create_gui, which is responsible for creating the basic GUI structure for our program.

The create_gui method simply delegates the task to five separate methods, each being responsible for creating one section of the GUI as follows (see code 6.01.py):

def create_gui(self):  self.create_menu() self.create_top_bar() ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required