O'Reilly logo

Tkinter GUI Programming by Example by David Love

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

Tying it all together

Let's begin with the ability to add a friend, since we need this to make the rest of our changes work properly.

We already have a Friends menu in the top menu bar of our FriendsList class containing an Add Friend command, which seems appropriate for this functionality. We'll replace the placeholder method with a functioning one:

def __init__(self, **kwargs):    ...    self.friends_menu.add_command(label="Add Friend", command=self.show_add_friend_window)    ...def show_add_friend_window(self):    AddFriendWindow(self)

In order to take the information, we need to add a friend and we will require a new Toplevel window. Go ahead and create a file named addfriendwindow.py alongside your friendslist.py file:

import tkinter as tkimport ...

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