TypeError: object.__init__() takes exactly one argument (the instance to initialize)

前端 未结 1 1969
自闭症患者
自闭症患者 2021-02-15 08:07

I am trying to make a form app and I don t understand the error:

TypeError: object.__init__() takes exactly one argument (the instance to initialize)

1条回答
  •  余生分开走
    2021-02-15 08:39

    OK, so the error is actually not in your super(Grid1,self).__init__(**kwargs) statement, it's in the creation of the Submit button. You did:

    self.submit = Button(text="Submit", font=40)
    self.add_widget(self.submit)
    

    But as the docs say, the font size is set by font_size and not font. The code should be:

    self.submit = Button(text="Submit", font_size=40)
    self.add_widget(self.submit)
    

    This should work just fine.

    Edit

    Just want to thank @chepner for pointing this out:

    Note that the issue, then, is that font, not being recognized by Button (or anyone else), is simply passed on up the chain until it is ultimately passed to object.__init__ (which raises an error instead of simply ignoring unexpected arguments).

    0 讨论(0)
提交回复
热议问题