Reputation: 311
I tried to make a program with a screen manager an images you can click on. I first I tried to store the kivy file within a string variable and return the string variable, but I got this error message:
kivy.factory.FactoryException: Unknown class <BILD1>
So I tried to return the Screenmanager, but it did not seem to work. I still got the same error message, could you please help me. Here is the rest of my source code:
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()
Upvotes: 2
Views: 1714
Reputation: 256
Move your Builder.load_file('turf.kv') like so:
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()
Upvotes: 2