'Screen manager not working whenever creating multiple screens
I am trying to make a quiz game with multiple windows. The first window is defining the rules of the game and the second window will have the game and its questions. But whenever i am trying to run the program facing with the same issue again and again. The complier says
kv = Builder.load_file('StandAloneQuiz.kv')
File "/home/shazam/.local/lib/python3.8/site-packages/kivy/lang/builder.py", line 305, in load_file
return self.load_string(data, **kwargs)
File "/home/shazam/.local/lib/python3.8/site-packages/kivy/lang/builder.py", line 407, in load_string
self._apply_rule(
File "/home/shazam/.local/lib/python3.8/site-packages/kivy/lang/builder.py", line 620, in _apply_rule
cls = Factory_get(cname)
File "/home/shazam/.local/lib/python3.8/site-packages/kivy/factory.py", line 147, in __getattr__
raise FactoryException('Unknown class <%s>' % name)
kivy.factory.FactoryException: Unknown class <IndexPage>
Here is the code for .kv file:
#:kivy 2.1.0
ScreenManager:
IndexPage:
Quizstart:
<IndexPage>:
name:"Instruction"
BoxLayout:
orientation:'vertical'
padding:10
spacing:8
Label:
text:'Rules of the Game'
font_size:25
Label:
text:'1. Time limit of the quiz is 10 min\n2. Only 1 option is correct choose wisely.\n3. Good luck.'
Button:
text:'Start'
# id:startquiz
on_release:
app.root.current:'Quizwin'
root.manager.transition.direction='right'
<Quizstart>:
name:"QuizWin"
BoxLayout:
orientation:'vertical'
padding:10
spacing:8
Label:
text:'Questions will arrive shortly'
Button:
text:'goBack'
on_release:
app.root.current:'Instruction'
root.manager.transition.direction='left'
Here is the code for main .py file:
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import Screen,ScreenManager
kv = Builder.load_file('StandAloneQuiz.kv')
class IndexPage(Screen):
pass
class Quizstart(Screen):
pass
class ScreenManagerial(ScreenManager):
pass
class StandAlone(App):
def build(self):
return kv
if __name__=="__main__":
StandAlone().run()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
