【发布时间】:2019-10-31 21:15:45
【问题描述】:
尝试创建 Listbox 的子类,以便创建新的 KeyListbox
from tkinter import *
class KeyListbox(Listbox):
def __init__(self,parent,**kwargs):
super().__init__(self,parent,**kwargs)
root = Tk()
root.title("Key List Test")
testlist=[ "Python" , "Perl" , "C" , "PHP" , "JSP" , "Ruby"]
lijst = KeyListbox(root,selectmode='multiple')
for i in testlist:
lijst.insert(END,i)
lijst.pack(root)
root.mainloop()
AttributeError: 'KeyListbox' 对象没有属性 'tk'
【问题讨论】:
标签: python tkinter listbox subclass