Beginner question - class definition error

David Aldrich David.Aldrich at EMEA.NEC.COM
Wed Jan 28 12:10:54 CET 2015


I am just getting started with Python 3.3.3 and Kivy 1.8.

I am using the Kivy  development environment on Windows (open a command prompt and call kivy.bat).

With this minimal code:

import kivy

from import App
from kivy.uix.label import Label

class MyApp(App):
  def build(self):
    return Label(text='Hello World')

  if __name__ == '__main__':

I get this error when I run it:

[INFO              ] Kivy v1.8.0
[INFO              ] [Logger      ] Record log in <snip>
[INFO              ] [Factory     ] 157 symbols loaded
[DEBUG          ] [Cache       ] register <kv.lang> with limit=None, timeout=Nones
[DEBUG          ] [Cache       ] register <kv.image> with limit=None, timeout=60s
[DEBUG          ] [Cache       ] register <kv.atlas> with limit=None, timeout=Nones
[INFO              ] [Image       ] Providers: img_tex, img_dds, img_pygame, img_gif (img_pil ignored)
[DEBUG          ] [Cache       ] register <kv.texture> with limit=1000, timeout=60s
[DEBUG          ] [Cache       ] register <kv.shader> with limit=1000, timeout=3600s
[INFO              ] [Text        ] Provider: pygame
 Traceback (most recent call last):
   File "", line 7, in <module>
     class MyApp(App):
   File "", line 12, in MyApp
 NameError: name 'MyApp' is not defined

How can I fix this please?

Best regards


More information about the Python-list mailing list