我正在做一个测验,每当我运行它时,我的代码总是出现错误。我正在使用 tkinter,这对我来说很新。有谁知道如何解决这个问题?
TypeError: __init__() takes 1 positional argument but 2 were given
def name_collection(self):
name = self.entry_box.get()
if str.isalpha(name) == True and len(name) >0 and len(name) <=10:
name_list.append(name)
Start(root)
elif str.isalpha(name) == False:
messagebox.showerror("Please enter your name again:","Check you are only using alphabetical letters. Special characters and numbers cannot be accepted.")
elif len(name) <0:
messagebox.showerror("Please enter your name again:","Please check you have entered your name before you continue")
elif len(name) >10:
messagebox.showerror("Please enter your name again:","Make sure you've entered a name up to 10 characters")
name_list.append(name)
self.quiz_frame.grid_forget()
self.quiz_frame.forget()
Close(root)
class Close:
def __init__ (self):
background = "Oldlace"
self.close_box.title("Close box")
self.close_frame = Frame (self.close_box, width=1000, height = 1000, bg = background)
self.close_frame.grid()
close_heading = Label (self.close_frame, text = 'Well Done', font = ('Tw Cen Mt',22, 'bold'), bg = background, pady = 15)
close_heading.grid(row = 4, pady = 20)```