user5332025 user5332025 - 2 months ago 35
Python Question

Kivy App Error- Invalid instance in App.root

I am working on building a kivy app. The below code is a simple Hello World of sorts. Press a button. The label changes from 'Hello' to 'World'

import kivy
kivy.require('1.9.1') # replace with your current kivy version !

from import App
from kivy.uix.button import Button
from kivy.uix.label import Label
#from tasks import assign_task

class GetTask():
def __init__(self, **kwargs):

self.main_label = Label(text = "Hello")
button = Button(text="Press")
button.bind(on_press= self.update)

def update(self):
self.main_label.text = "World"

class MyApp(App):
def build(self):
return GetTask()

if __name__ == '__main__':

The error I get when I run it is:

raise Exception('Invalid instance in App.root')
Exception: Invalid instance in App.root

I looked at this- Kivy: Invalid instance in App.root

I still cannot figure what I am doing wrong. Please help. Thank you.


What does your GetTask inherit from? It seems to me that it doesn't inherit from anything at all. Try changing it to

class GetTask(Widget):
    #  The rest is like it's in your code.

Also have a look at my comment under the question. Not sure if it's still the issue in 1.9.1, though.