tkinter TypeError:\uuuu init\uuuuu()接受1个位置参数,但给出了2个

2024-09-30 01:24:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我在做一个测试,每次运行代码时都会发现代码中有错误。我正在使用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)```

Tags: andnameselfboxyoucloseyourlen

热门问题