Skip to Content
Tkinter GUI Programming by Example
book

Tkinter GUI Programming by Example

by David Love
April 2018
Beginner content levelBeginner
340 pages
7h 54m
English
Packt Publishing
Content preview from Tkinter GUI Programming by Example

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): ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Tkinter GUI Application Development Blueprints, Second Edition - Second Edition

Tkinter GUI Application Development Blueprints, Second Edition - Second Edition

Bhaskar Chaudhary

Publisher Resources

ISBN: 9781788627481Supplemental Content