def load_friends(self):
    my_friends = self.requester.get_friends(self.username)
    for user in my_friends['friends']:
        if (user['username'] != self.username):
            friend_frame = ttk.Frame(self.canvas_frame)
            friend_avatar_path = os.path.join(friend_avatars_dir, f"{user['username']}.png")
            if user['avatar']:
                with open(friend_avatar_path, 'wb') as friend_avatar:
                    img = base64.urlsafe_b64decode(user['avatar'])
                    friend_avatar.write(img)
            else:
                friend_avatar_path = default_avatar_path
            profile_photo = tk.PhotoImage(file=friend_avatar_path)
            profile_photo_label = ttk.Label(friend_frame, image=profile_photo)
            profile_photo_label.image = profile_photo
            friend_name = ttk.Label(friend_frame, text=user['real_name'], anchor=tk.W)
            message_this_friend = partial(self.open_chat_window, username=user['username'], real_name=user['real_name'], avatar=friend_avatar_path)
            block_this_friend = partial(self.block_friend, username=user['username'])
            message_button = ttk.Button(friend_frame, text='Chat', command=message_this_friend)
            block_button = ttk.Button(friend_frame, text='Block', command=block_this_friend)
            profile_photo_label.pack(side=tk.LEFT)
            friend_name.pack(side=tk.LEFT)
            message_button.pack(side=tk.RIGHT)
            block_button.pack(side=tk.RIGHT, padx=(0, 30))
            friend_frame.pack(fill=tk.X, expand=1)
def load_friends(self):
    my_friends = self.requester.get_friends(self.username)
    for user in my_friends['friends']:
        if (user['username'] != self.username):
            friend_frame = ttk.Frame(self.canvas_frame)
            friend_avatar_path = os.path.join(friend_avatars_dir, f"{user['username']}.png")
            if user['avatar']:
                with open(friend_avatar_path, 'wb') as friend_avatar:
                    img = base64.urlsafe_b64decode(user['avatar'])
                    friend_avatar.write(img)
            else:
                friend_avatar_path = default_avatar_path
            profile_photo = tk.PhotoImage(file=friend_avatar_path)
            profile_photo_label = ttk.Label(friend_frame, image=profile_photo)
            profile_photo_label.image = profile_photo
            friend_name = ttk.Label(friend_frame, text=user['real_name'], anchor=tk.W)
            message_this_friend = partial(self.open_chat_window, username=user['username'], real_name=user['real_name'], avatar=friend_avatar_path)
            block_this_friend = partial(self.block_friend, username=user['username'])
            message_button = ttk.Button(friend_frame, text='Chat', command=message_this_friend)
            block_button = ttk.Button(friend_frame, text='Block', command=block_this_friend)
            profile_photo_label.pack(side=tk.LEFT)
            friend_name.pack(side=tk.LEFT)
            message_button.pack(side=tk.RIGHT)
            block_button.pack(side=tk.RIGHT, padx=(0, 30))
            friend_frame.pack(fill=tk.X, expand=1)