Setting up a broad GUI structure
Let's now set up the broad GUI elements of our program. We 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 framework class 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() self.create_tool_bar() self.create_drawing_canvas() self.bind_menu_accelrator_keys()
These five methods together build a structure as shown in the following figure (see code 6.01.py...