我不知道为什么错误显示它有3个参数。任何人都可以帮忙TypeError:__init __()需要2个参数(给出3个)
Traceback:
line 23, in __init__
frame = F(self, container)
TypeError: __init__() takes exactly 2 arguments (3 given)
代码:
class CGPACalculator(Tkinter.Tk):
def __init__(self, *args, **kwargs):
Tkinter.Tk.__init__(self, *args, **kwargs)
container = Tkinter.Frame(self)
container.pack(side="top", fill="both", expand=True)
container.grid_rowconfigure(0, weight=1)
container.grid_columnconfigure(0, weight=1)
self.frames = {}
for F in (Page1, Page2):
frame = F(self, container)
self.frames[F] = frame
frame.grid(row=0, column=0, sticky="nsew")
self.show_frame(Page1)
'F(容器)'...你应该真的去阅读一些有关python类的教程... self总是隐式地传递给instanciated类方法 –
但是在我删除“self”后,GUI没有出来。 –
@JoranBeasley:或'F(self)'如果'self'是父母。 –