Let's take a look at the following steps for preparing our MainMenu class:
- To begin, let's create a new file in our module called mainmenu.py.
- Cut the entire MainMenu class out of views.py and paste it into mainmenu.py. The first thing we'll do is change its name to explain its role more clearly:
- In order to make it easier for subclasses to build different menu structures, we're going to split all the code that creates the menu widgets into their own method. We'll call this method _build_menu():
def _build_menu(self): # The file menu file_menu = tk.Menu(self, tearoff=False) ...
- Move the entire __init__() method after the call to super() into this method. Each of our child ...