python - NameError: global name 'END' is not defined -
I think this code about scrollbar is working just fine. Tkinter import * master = Tk () scrollbar = scrollbar (master) from I try to use it in my code like this: But when I went above the code, I found an error on the on the insertion line. By the way, I tried to find the documentation and found the closest I could but still could not understand What is wrong? Or you can import them explicitly if you wish : scrollbar.pack (side = right, fill = y) listbox = listbox (master, yscrollcommand = scrollbar.set) For the range (10000): listbox.insert (END, str (i)) listbox.pack (side = LEFT, fill = both) scrollbar.config (command = listbox.yview) mainloop ()
Teak Class Interface (tk.Frame) as imported tanker: def __init __ (self, den) : self.tklist () #in My code, tklist is not called here. I have called it here to reduce the code here. There are also things here: tklist (scroller), yscrollcommand = scrollbar.set) in category i (1000): self.lst1.insert (END, str (i)) self.lst1.pack (side = LEFT, fill = Both) scrollbar.config (command = lst1. Yview) den = tk.Tk () den.title ("search") inter = interface (den) den.mainloop ()
name error: global name 'END' is not defined
END ,
left , and
Both all
tkinter remain in the namespace. Thus, they have
tk They need to be qualified by entering :
for i category (1000): self.lst1.insert (tk.END, str (i)) self.lst1. Scroll (side = tk.LEFT, fill = tk.BOTH) scrollbar.config (command = lst1.yview)
import two types, END, LEFT
Comments
Post a Comment