gpt4 book ai didi

python - Kivy类工厂错误

转载 作者:太空宇宙 更新时间:2023-11-04 03:37:22 25 4
gpt4 key购买 nike

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

 kivy.factory.FactoryException: Unknown class <BILD1>

所以我尝试返回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()

关于python - Kivy类工厂错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28329139/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com