NameError: global name ‘END’ is not defined

END, LEFT, and BOTH all reside in the tkinter namespace. Thus, they need to be qualified by placing tk. before them:

for i in range(1000):
    self.lst1.insert(tk.END, str(i))
self.lst1.pack(side=tk.LEFT, fill=tk.BOTH)
scrollbar.config(command=lst1.yview)

Or, you could import them explicitly if you want:

from tkinter import BOTH, END, LEFT

Leave a Comment