'Kivy Exception: Unknown class <GpsBlinker>
Running my code seems to end in an Exception error, I have tried for a long time to debug this but I couldn't do it
main.py
from kivy.animation import Animation
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import Screen, ScreenManager, FadeTransition
from gpshelper import GpsHelper
import plyer
class Manager(ScreenManager):
pass
class SelectionScreen(Screen):
def on_start(self):
GpsHelper().run()
class Game(Screen):
pass
class GpsBlinker():
def blink(self):
anim = Animation(opacity=0, blink_size=50)
anim.bind(on_complete=self.reset)
anim.start(self)
def reset(self, *args):
self.opacity = 1
self.blink_size = self.default_blink_size
self.blink()
kv = Builder.load_file("hiby.kv")
class HeIsBehindYou(App):
def build(self):
return kv
if __name__ == '__main__':
HeIsBehindYou().run()
main.kv
#:import FadeTransition kivy.uix.screenmanager.FadeTransition
Manager:
transition: FadeTransition()
SelectionScreen:
name:'selectionscreen'
Game:
name:'game'
<GpsBlinker>
default_blink_size: 25
blink_size: 25
canvas.before:
Color:
rgba: 0.5, 0.5, 0.5, 1
RoundedRectangle:
radius:[root.blink_size/2.0, ]
size: [root.blink_size, root.blink_size]
pos: root.pos[0] + root.size[0]/2.0 - root.blink_size/2.0, root.pos[1] + root.size[1]/2.0 - root.blink_size/2.0
<SelectionScreen>
BoxLayout:
Image:
source: 'placeholder.png'
size: self.texture_size
Button:
text: 'Start Day 1'
on_release:
app.root.current = "game"
root.manager.transition.direction = "up"
print("inside")
root.on_start()
<Game>
id: game
BoxLayout:
orientation: 'vertical'
Image:
source: 'digital-grid-background.jpg'
size: self.texture_size
size_hint: 1, 3
GpsBlinker:
id: blinker
After I run this I get the following error:
raise FactoryException('Unknown class <%s>' % name)
kivy.factory.FactoryException: Unknown class <GpsBlinker
I tried to make a gps module to that overlays an animation in the game(screen). Even tho I have it defined in the main.py file, I still get this error
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
