我对OOP和GUI都是新手。我正在使用python使用tkinter创建顶级。这个顶级由两个类组成,其中一个继承另一个的属性和实例函数。但我无法读取并获取某个类的init方法中存储的一些值。我该怎么做
我没有办法解决这个问题
班级布局(tk.顶层):
def __init__(self, title, labelName):
tk.Toplevel.__init__(self)
self.title(title)
…其他小部件
self.Scrolly = tk.Scrollbar(self)
self.Scrollx = tk.Scrollbar(self)
self.Listbox = tk.Listbox(self)
self.Listbox.configure(selectmode=tk.MULTIPLE, yscrollcommand=self.Scrolly.set,
xscrollcommand=self.Scrollx.set)
self.Listbox.insert(tk.END, "ciao")
self.Scrolly.configure(command=self.Listbox.yview())
self.Scrollx.configure(command=self.Listbox.xview(), orient=tk.HORIZONTAL)
self.Scrolly.grid(row=1 , column=0, rowspan=5)
self.Scrollx.grid(row=6, column=1)
self.Listbox.grid(row=1, column=1, rowspan=5)
与函数关联的其他小部件
def add(self):... #add elements to Listbox
def Remove(self, opt=None):...
类模块功能(布局):
def __init__(self):
super().__init__("Aggiungi/rimuovi esercizi", "Esercizi:")
self.Populate_list()
def Populate_list(self):
print(super().Listbox.get(0, tk.END))
错误: 在列表中 打印(super().Listbox.get(0,tk.END)) AttributeError:“super”对象没有属性“Listbox”
您应该能够调用
self.Listbox.get(0, tk.END)
Mod_features
扩展了Layout
,因此Listbox
也应该是Mod_features
的成员相关问题 更多 >
编程相关推荐