Kivy: INVALID PROPERTY NAME

Asked

Viewed 143 times

0

I created a program in Python and Kivy, but it only gives error!

PYTHON PROGRAM:

kivy.require("1.11.1")
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.floatlayout import FloatLayout

def Ridget(FloatLayout):
    pass

class aplication(App):
    def build(self):
        return Ridget


window = aplication()
window.run()

KIVY PROGRAM:

<Ridget>:
    Button:
        text: 'Hi'

ERROR MESSAGE:

   1:

2: :

   3:        Button:

   4:            text: 'Hi'

Invalid Property name

2 answers

0

python:

import kivy
kivy.require("1.11.1")
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.floatlayout import FloatLayout

def Ridget(FloatLayout):
    pass

class Aplication(App):
    def build(self):
        return Ridget

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

In the kivy file add the extension type in the header, this way: #:kivy 1.0, sometimes without this the kivy does not work properly or even does not recognize the file.

Kv:

#:kivy 1.0
<Ridget>:
    Button:
        text:"Hi"

Try this way.

0

its first function Ridget actually has to be a class because the <Ridget> in the archive .kv is an instance of her.

class Ridget(FloatLayout):
    pass

it is also good practice to let the class name always start with uppercase letter, so I would exchange aplication for Application, but that’s just a suggestion.

Anyway, I tested the following code here and it worked:

class Ridget(FloatLayout):
    pass

class Application(App):
    def build(self):
        return Ridget()

window = Application()
window.run()

I hope it helps somehow.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.