Search code examples
pythonkivy

I am very new to kivy and i was following this youtuber called Tech with Tim, the following happened after his Kivy Tutorial #4


so i have the very basic python code and i wanted to create a kv file for it. i am on visual studio btw, just a reference. i have tried changing the #kivy tag. it didnt work i dont know how to fix it, its daunting, please help. My code is as follows

the kv file is like this:

#:kivy 2.0.0 : GridLayout: cols: 1

    Gridlayout:
        cols: 2

        Label:
            text: "Name: "
        
        TextInput:
            multiline: False

        Label:
            text: "Email: "    
        TextInput:
            multiline: False
    Button:
        text: "Submit"

i am getting this error :

 raise FactoryException('Unknown class <%s>' % name), kivy.factory.FactoryException: Unknown class <Gridlayout>

kivy.require('2.0.0')
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.uix.textinput import TextInput
from kivy.uix.button import Button
from kivy.uix.widget import Widget


class CoolGrid(Widget):
    the details here

class CoolApp(App):
    def build(self):
        return CoolGrid()

if __name__ == "__main__":
    CoolApp().run()```


Solution

  • Error is in the first line in your kv file. Change Gridlayout for GridLayout (capital L)

    All classes name in kivy are like this, the first letter of any word are capital letters: GridlLayout, BoxLayout, TextInput