Python Forum
[Kivy] NameError: name 'App' is not defined
Thread Rating:
  • 2 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Kivy] NameError: name 'App' is not defined
#1
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
Reply
#2
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.
Reply
#3
you need to import App....you also need to import Label as well

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

[Image: erjwgd]
Reply
#5
(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
Recommended Tutorials:
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  NameError: name 'self' is not defined hobbyist 30 14,421 Jul-25-2021, 10:22 AM
Last Post: hobbyist
  [WxPython] NameError: global name 'PyAssertionError' is not defined merlem 5 6,251 Jan-28-2017, 01:59 PM
Last Post: merlem

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020