N
N
Nikolai Getmanov2020-10-29 15:22:00
Python
Nikolai Getmanov, 2020-10-29 15:22:00

How to get rid of TypeError TypeError: object.__init__() takes no arguments if I have no objects in the class?

Good afternoon! There is an application in Kivy, and inside the program there is a class that does not allow me to run the program without errors. Where is the error that causes the program to finish compiling?

from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.floatlayout import FloatLayout
from kivy.config import Config
import matplotlib.colors as colors

def hexToRGB(parameter):
    rgba = list(colors.hex2color(parameter))
    rgba[0] = int(rgba[0])
    rgba[1] = int(rgba[1])
    rgba[2] = int(rgba[2])


    rgba.append(1)
    return list(rgba)

Config.set('graphics', 'resizable', '0')
Config.set('graphics', 'width', '500')
Config.set('graphics', 'height', '500')

class MyApp(App):

    title = 'Моя первая приложка!'

    def build(self):

        calc_label = FloatLayout(size=(300, 300))

        calc_label.add_widget(Label(text="Hello World",
                      font_size=30,
                      background_color = hexToRGB('#2E8B57'),
                      background_normal = '',
                      size_hint = (.99, .1),
                      pos = (0, 500/2)));
        return calc_label
if __name__ == "__main__":
    MyApp().run()


Error:
Traceback (most recent call last):
File "main.py", line 38, in
MyApp().run()
File "C:\Users\USER\AppData\Local\Programs\Python\Python37\lib\site -packages\kivy\app.py", line 829, in run
root = self.build()
File "main.py", line 35, in build
pos = (0, 500/2)));
File "C:\Users\USER\AppData\Local\Programs\Python\Python37\lib\site-packages\kivy\uix\label.py", line 318, in __init__
super(Label, self).__init__(** kwargs)
File "C:\Users\USER\AppData\Local\Programs\Python\Python37\lib\site-packages\kivy\uix\widget.py", line 350, in __init__
super(Widget, self).__init__( **kwargs)
File "kivy\_event.pyx", line 243, in kivy._event.EventDispatcher.__init__
TypeError: object.__init__() takes no arguments

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2020-10-29
@Kolya_Get

Remove all background_options

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question