Skip to content
Snippets Groups Projects
Commit a91f9dd9 authored by okreikemeier2's avatar okreikemeier2
Browse files

Added a progress bar that is linked to the numbers of questions answered....

Added a progress bar that is linked to the numbers of questions answered. Added code that links the question number displayed with the number of questions answered so it increases with each question.
parent aeba1054
Branches
No related tags found
No related merge requests found
...@@ -77,6 +77,7 @@ class QuizzerApp(App): ...@@ -77,6 +77,7 @@ class QuizzerApp(App):
correct = BooleanProperty(False) correct = BooleanProperty(False)
score = NumericProperty(0) score = NumericProperty(0)
num_answered = NumericProperty(0)
def build(self): def build(self):
inspector.create_inspector(Window, self) inspector.create_inspector(Window, self)
...@@ -118,6 +119,7 @@ class QuizzerApp(App): ...@@ -118,6 +119,7 @@ class QuizzerApp(App):
self.paused = False self.paused = False
if self.correct == True: if self.correct == True:
app.score+=100 app.score+=100
self.num_answered += 1
if len(self.questions) > 0: if len(self.questions) > 0:
self.questions.pop() self.questions.pop()
if len(self.questions) == 0: if len(self.questions) == 0:
......
...@@ -78,13 +78,20 @@ ScreenManager: ...@@ -78,13 +78,20 @@ ScreenManager:
root.transition.direction = 'right' root.transition.direction = 'right'
root.current = 'settings' root.current = 'settings'
Label: Label:
text: 'Do you know…' text: f'Question {app.num_answered+1}'
font_size: sp(24) font_size: sp(24)
size_hint: (1, None) size_hint: (1, 1)
size: (self.texture_size[0] + 64, self.texture_size[1] + 64) size: (self.texture_size[0] + 64, self.texture_size[1] + 64)
ProgressBar:
id: progress_bar
min :0
max: 5
value: app.num_answered
pos_hint:{'x':.1}
size_hint_x: .8
Label: Label:
text: f'Score: {app.score}' text: f'Score: {app.score}'
font_size: sp(24) font_size: sp(16)
size_hint: (1, None) size_hint: (1, None)
size: (self.texture_size[0] + 64, self.texture_size[1] + 64) size: (self.texture_size[0] + 64, self.texture_size[1] + 64)
Label: Label:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment