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

Creating our FriendsList class

Begin with a new folder, which will hold all of the code for our chat application. Inside this folder, create a file called friendslist.py. In this file, we will begin writing our FriendsList class:

import tkinter as tkimport tkinter.ttk as ttkclass FriendsList(tk.Tk):    def __init__(self, **kwargs):        super().__init__(**kwargs)        self.title('Tk Chat')        self.geometry('700x500')        self.canvas = tk.Canvas(self, bg="white")        self.canvas_frame = tk.Frame(self.canvas)        self.scrollbar = ttk.Scrollbar(self, orient="vertical",                                         command=self.canvas.yview)        self.canvas.configure(yscrollcommand=self.scrollbar.set)        self.scrollbar.pack(side=tk.LEFT, fill=tk.Y)        self.canvas.pack(side=tk.LEFT, expand=1, fill=tk.BOTH)        self.friends_area ...

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