kivy program returns the following error when i run it

254 views
Skip to first unread message

Marrion Martin

unread,
Jun 18, 2017, 10:28:42 AM6/18/17
to Kivy users support
hi everyone im knew to kivy and learning it by myself, so i wrote this weather app program and when i try to run i receive the following error:

[INFO   ] [Logger      ] Record log in /root/.kivy/logs/kivy_17-06-19_5.txt
[INFO   ] [Kivy        ] v1.9.1
[INFO   ] [Python      ] v2.7.13 (default, Jan 19 2017, 14:48:08)
[GCC 6.3.0 20170118]
[INFO   ] [Factory     ] 179 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_gif, img_sdl2, img_pil (img_ffpyplayer ignored)
 Traceback (most recent call last):
   File "main.py", line 15, in <module>
     WeatherApp().run()
   File "/usr/lib/python2.7/dist-packages/kivy/app.py", line 801, in run
     self.load_kv(filename=self.kv_file)
   File "/usr/lib/python2.7/dist-packages/kivy/app.py", line 598, in load_kv
     root = Builder.load_file(rfilename)
   File "/usr/lib/python2.7/dist-packages/kivy/lang.py", line 1842, in load_file
     return self.load_string(data, **kwargs)
   File "/usr/lib/python2.7/dist-packages/kivy/lang.py", line 1920, in load_string
     widget = Factory.get(parser.root.name)()
   File "/usr/lib/python2.7/dist-packages/kivy/factory.py", line 131, in __getattr__
     raise FactoryException('Unknown class <%s>' % name)
 kivy.factory.FactoryException: Unknown class <AddLocationForm>

(main.py file)

from kivy.app import App
from kivy.uix.boxlayout import BoxLayout

class AddLocatonForm(BoxLayout):
    def search_location(self):
        print('Explicit is better than Implicit')
   


class WeatherApp(App):
    pass


if __name__ == '__main__':
        WeatherApp().run()

(weather.kv file)

AddLocationForm:


<AddLocationForm>:
    orientation: 'vertical'
    BoxLayout:
        height: "40dp"
        size_hint_y: None
        TextInput:
            size_hint_x: 50
        Button:
            text: 'Search'
            size_hint_x: 25
            on_press:root.search_location()
        Button:
            text: 'Current Location'
            size_hint_x: 25
    ListView:
        item_strings: ['Makunyane Zanele, PTA', 'Makunyane Olivia, GP']

could anyone please tell me what im doing wrong.
thanks in advance

Marrion

Mox

unread,
Jun 18, 2017, 11:08:44 AM6/18/17
to Kivy users support
2 problems: 1. You have a typo in your spelling of AddLocation, your missing the 'i' in your class declaration. 2. you don't return anything in your WeatherApp class. You need to define the build method:

def build(self):
    return AddLocationForm()
Reply all
Reply to author
Forward
0 new messages