沮丧 class 工厂错误

Kivy class factory error

我尝试制作一个带有屏幕管理器的程序,您可以点击图像。 我首先尝试将 kivy 文件存储在字符串变量和 return 字符串变量中,但我收到此错误消息:

 kivy.factory.FactoryException: Unknown class <BILD1>

所以我尝试 return Screenmanager,但它似乎没有用。 我仍然收到相同的错误消息,你能帮帮我吗? 这是我的源代码的其余部分:

class Auswahl(Screen):
    pass
class Frage(Screen):
    farbe = ListProperty([1, 1, 1, 1])
    def druck(self):
        self.farbe = ([1, 0, 0, 1])
        self.ids.box1.clear_widgets()
        wimg = Image(source='Bild1.png')
        self.ids.box1.add_widget(wimg)

class Troll(Screen):
    pass

class Manager(ScreenManager):
    pass

Builder.load_file('turf.kv')

class BILD1(Widget):
    velocity = ListProperty([1, 0])
    def __init__(self, **kwargs):
        super(Knopf, self).__init__(**kwargs)
        Clock.schedule_interval(self.Update, 1/60.)
    def Update(self, *args):
        pass
    def on_touch_down(self, touch):
        if self.collide_point(*touch.pos):
            print 'es geht'
class BILD2(Knopf):
    def on_touch_down(self, touch):
        if self.collide_point(*touch.pos):
            print 'es geht'
class BILD3(Knopf):
    def on_touch_down(self, touch):
        if self.collide_point(*touch.pos):
            print 'es geht'
class BILD4(Knopf):
    def on_touch_down(self, touch):
        if self.collide_point(*touch.pos):
            print 'es geht'



class TurF(App):
    def build(self):
        return Manager()

TurF().run()

像这样移动你的Builder.load_file('turf.kv'):

class Auswahl(Screen):
    pass
class Frage(Screen):
    farbe = ListProperty([1, 1, 1, 1])
    def druck(self):
        self.farbe = ([1, 0, 0, 1])
        self.ids.box1.clear_widgets()
        wimg = Image(source='Bild1.png')
        self.ids.box1.add_widget(wimg)

class Troll(Screen):
    pass

class Manager(ScreenManager):
    pass



class BILD1(Widget):
    velocity = ListProperty([1, 0])
    def __init__(self, **kwargs):
        super(Knopf, self).__init__(**kwargs)
        Clock.schedule_interval(self.Update, 1/60.)
    def Update(self, *args):
        pass
    def on_touch_down(self, touch):
        if self.collide_point(*touch.pos):
            print 'es geht'
class BILD2(Knopf):
    def on_touch_down(self, touch):
        if self.collide_point(*touch.pos):
            print 'es geht'
class BILD3(Knopf):
    def on_touch_down(self, touch):
        if self.collide_point(*touch.pos):
            print 'es geht'
class BILD4(Knopf):
    def on_touch_down(self, touch):
        if self.collide_point(*touch.pos):
            print 'es geht'



Builder.load_file('turf.kv')

class TurF(App):
    def build(self):
        return Manager()

TurF().run()