【发布时间】:2013-08-05 21:19:06
【问题描述】:
我会假设原因与我得到的 self 相似。为什么 master 在那里?另外,为什么有时是master,有时是master = none?
例如
class Application(tk.Frame):
def __init__(self, master=None):
tk.Frame.__init__(self, master)
self.grid()
self.createWidgets()
来自 Tkinter 8.5 参考:John W. Shipman 的 Python 图形用户界面。此外,文档使用 python2,而我将使用 python3。我需要主人吗? 更多问题 我尝试在 master 之后添加自定义 arg,它说我无法在默认值之后添加非默认 arg,我应该如何解决?不是默认的 arg self 必须是第一个吗?
def __init__(self, master=None,inputDict):
tk.Frame.__init__(self, master)
self.grid(sticky=tk.N+tk.S+tk.E+tk.W)
self.createWidgets()
def createWidgets(self,inputDict):
top=self.winfo_toplevel()
top.rowconfigure(0, weight=1)
top.columnconfigure(0, weight=1)
self.rowconfigure(0, weight=1)
self.columnconfigure(0, weight=1)
tempDict = {}
for k,v in inputDict.items():
if 1<=v[0]<=3:
tempDict[k] = static_keys(*v[1:])
elif v[0] ==4:
tempDict[k] = dynamic_keys(*v[1:])
elif v[0]==5:
tempDict[k] = key_labels(*v[1:])
return tempDict
【问题讨论】:
标签: python class python-2.7 python-3.x tkinter