Skip to content Skip to sidebar Skip to footer

Getting Typeerror: Object.__init__() Takes No Parameters Kivy

I developed an app with python and faced this problem: TypeError: object.__init__() takes no parameters My files are the following : Main.py: from kivy.app import App from kivy.la

Solution 1:

As inclement stated out correctly you pass an argument to the class that does not exist C = ClinicBanner(cities=row[1]). It is the cities argument. If you use it this way you better write your init method like this:

def __init__(self, cities, **kwargs): 
    super(ClinicBanner, self).__init__(**kwargs) 

    centre = FloatLayout() centre_label = Label(text=cities, size_hint=(1, .2), pos_hint={"top": .2, "left": 1}) 

I added cities to the init method as an argument and changed the labels text to cities (I assume cities is a str). This way it should work, but if you create a new instance of ClinicBanner you now always have to add a cities argument. If you dont want that you can change the init method to def __init__(self, cities="", **kwargs): to add an empty string as default. I hope, it now works for you.

Solution 2:

The error means you're passing arguments to the superclass that it does not expect. In this case it's probably the cities argument, but I didn't look closely. Don't pass the argument to the parent because the parent doesn't have anything to do with it.

Post a Comment for "Getting Typeerror: Object.__init__() Takes No Parameters Kivy"