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

Updating the FriendsList class

We still have a Friends menu at the top of our FriendsList class, but this doesn't make much sense as a place to put our avatar uploading functionality. Instead, we can create a new submenu called avatar:

...from avatarwindow import AvatarWindow...def __init__(self, **kwargs):    ...    self.avatar_menu = tk.Menu(self.menu, fg="black",                                bg="lightgrey", tearoff=0)    self.avatar_menu.add_command(label="Change Avatar",                                  command=self.change_avatar)    self.menu.add_cascade(label="Friends", menu=self.friends_menu)    self.menu.add_cascade(label="Avatar", menu=self.avatar_menu)

After importing our new class, we create a menu called avatar_menu to hold a Change Avatar function. This will call a method named change_avatar:

def change_avatar(self): ...

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