P
P
Player___12020-12-11 05:09:13
Python
Player___1, 2020-12-11 05:09:13

Python Kivy error object.__init__() takes exactly one argument?

Source code in Python Kivy:

from kivy.app import App

from kivy.uix.button import Button
from kivy.uix.gridlayout import GridLayout
from kivy.uix.label import Label
from kivy.uix.boxlayout import BoxLayout

from kivy.config import Config

Config.set('graphics','resizable',0)

class CalculatorApp(App):
  def build(self):
    bl = BoxLayout(orietation = 'vertical')
    gl = GridLayout(cols = 4)

    bl.add_widget( Label(text='0') )

    gl.add_widget( Button(text='7') )
    gl.add_widget( Button(text='8') )
    gl.add_widget( Button(text='9') )
    gl.add_widget( Button(text='x') )

    gl.add_widget( Button(text='4') )
    gl.add_widget( Button(text='5') )
    gl.add_widget( Button(text='6') )
    gl.add_widget( Button(text='-') )

    gl.add_widget( Button(text='1') )
    gl.add_widget( Button(text='2') )
    gl.add_widget( Button(text='3') )
    gl.add_widget( Button(text='+') )

    gl.add_widget( Button(text='C') )
    gl.add_widget( Button(text='0') )
    gl.add_widget( Button(text='.') )
    gl.add_widget( Button(text='=') )

    bl.add_widget( gl )
    return bl

if __name__ == "__main__":
  CalculatorApp().run()


On startup it gives an error:
TypeError: object.__init__() takes exactly one argument (the instance to initialize)


The error arose when I added lines related to BoxLayout, if they are deleted everything works fine, but I need BoxLayout, plus in the video I'm learning from, the code is the same and everything works, apparently the versions are different.
How can I fix the code so that it works?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrew, 2020-12-11
@Player___1

Typo

BoxLayout(orietation = 'vertical')  # опечатка
BoxLayout(orientation='vertical')

Attach the full trace of the error.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question