-1

Why does this code produce an error? I followed the tutorial (what I thought as perfectly):

from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.textinput import TextInput
from kivy.core.window import Window
import random

class MainApp(App):
    def build(self):
        label = Label(text="Remember me:/Rebecca")
        self.layout = BoxLayout(orientaion='vertical',size=(Window.width, Window.height))
        self.box = BoxLayout(orientation='horizontal', spacing=50, pos=(0,500))
        self.txt = TextInput(hint_text="Write here",size_hint=(.5,.1))
        self.box.add_widget(self.txt)
        self.layout.add_widget(self.box)
        self.layout.add_widget(self.label)
        return self.layout

if __name__ == '__main__':
    app = MainApp()
    app.run()

Error:

File "C:\Users\Rebecca.Bi\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 245, in kivy._event.EventDispatcher.__init__
 TypeError: object.__init__() takes exactly one argument (the instance to initialize)

This question does not solve my problem because the solutions do not sovle my problem. I tried everything they recommended, but it still doesn't work.

Any help is greatly appreciated!

user229044
  • 232,980
  • 40
  • 330
  • 338
Rebecca Bibye
  • 190
  • 2
  • 18

3 Answers3

1

The answer is to replace size and size_hint with size_small or size_large or whatever else size you want. With these commands, you can specify what size you want in kivy.

user229044
  • 232,980
  • 40
  • 330
  • 338
0

You miss-spelled orientaion. It should be orientation in:

self.layout = BoxLayout(orientaion='vertical',size=(Window.width, Window.height))
John Anderson
  • 35,991
  • 4
  • 13
  • 36
0

You miss-spelled orientation and passed self.label as an argument in self.layout.add_widget(self.label) instead of label.

Change label = Label(text="Remember me:/Rebecca") to self.label = Label(text="Remember me:/Rebecca") and it should work.

wuerfelfreak
  • 2,363
  • 1
  • 14
  • 29