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 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 ()

I try to use it in my code like this:

  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 ()   

But when I went above the code, I found an error on the on the insertion line.

  name error: global name 'END' is not defined   

By the way, I tried to find the documentation and found the closest I could but still could not understand What is wrong?

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)   

Or you can import them explicitly if you wish : import two types, END, LEFT

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -