Search code examples
pythonkivykivy-language

AttributeError: 'super' object has no attribute '__getattr__' in kivy .kv file


STILL, THIS IS SO ANNOYING, kv-kivy-this-that-error, UHH............ Anyway I don't seem to get kivy, Ok I'm STILL playing around in the .kv file and annoyingly and sluggishly gave up its 'typical' response

AttributeError: 'super' object has no attribute '__getattr__'

I feel dumbfounded what is this,WHY KIVY-anyway i must give something to show what really Is happening PYTHON

from kivy.app import App
from kivy.uix.widget import Widget
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.lang import Builder
from kivy.uix.textinput import TextInput
from kivy.uix.label import Label
Builder.load_file("my.kv")
class MyLayout(Widget,App):
    def __init__(self,*args,**kwargs):
        super(MyLayout, self).__init__(**kwargs)
    def clear(self):
        self.ids.n.text = ""
        self.ids.fp.text = ""
        self.ids.d.text = ""
    def writeD(self):
        name = self.ids.n.text
        pizza = self.ids.fp.text
        drinks = self.ids.d.text
        orders = open("order.txt","w")
        orders.write(f"Name: {name}\n")
        orders.write(f"Pizza: {pizza}\n")
        orders.write(f"Drinks: {drinks}")
    def read(self):
        orders = open("order.txt","r")
        orderL = orders.read()
        self.ids.layout.add_widget(Label(text=orderL))
class AwesomeApp(App):
   def build(self):
       return MyLayout()
if __name__ == '__main__':
    AwesomeApp().run()

Yeah like it is-- .kv

<Button>
    font_size:20
<TextInput>
    font_size:20
<Label>
    font_size:20
<MyLayout>
    BoxLayout:
        id: "layout"
        orientation:"vertical"
        size: root.width,root.height
        padding:10
        spacing:10
        Label:
            text:"Name"
        TextInput:
            id: n
            multiline:False
        Label:
            text:"Pizza"
        TextInput:
            id: fp
            multiline:False
        Label:
            text:"Drinks"
        TextInput:
            id: d
            multiline:False
        Button:
            text:"Submit"
            on_press:root.writeD()
        Button:
            text:"Clear fields"
            on_press:root.clear()
        Button:
            text:"show orders"
            on_press:root.read()

yup an attribute error again can anyone help.PYTHON


Solution

  • In your kv file, ids should not be strings. Try changing:

    id: "layout"
    

    to:

    id: layout