Python Forum

Full Version: NameError: name 'App' is not defined
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
import kivy

class MyApp(App):
   def build(self):
       return Label(text='Hello world')
Moderator Larz60+: Added code tags and removed formatting - Please see https://python-forum.io/misc.php?action=help&hid=25
You are passing App as an object to class, but haven't defined App
If you have nothing to inherent from, remove the (App) from class.
you need to import App....you also need to import Label as well

from kivy.app import App
from kivy.uix.label import Label
Ty all for your response. I mean, how do i change my syntaxist if i only use import kivy ?

[Image: erjwgd]
(Apr-02-2017, 04:13 PM)nengkya Wrote: [ -> ]Ty all for your response. I mean, how do i change my syntaxist if i only use import kivy ? [Image: erjwgd]
After looking at their code, it doesnt look like you will be able to do import kivy and do 

class MyApp(kivy.app.App):
   def build(self):
       return kivy.uix.label.Label(text='Hello world')
the closest you would come is this
import kivy.app
import kivy.uix.label
 
class MyApp(kivy.app.App):
   def build(self):
       return kivy.uix.label.Label(text='Hello world')
whihc you might as well just do
from kivy.app import App
from kivy.uix.label import Label