diff options
author | Wade Brainerd <wadetb@gmail.com> | 2008-11-21 16:48:13 (GMT) |
---|---|---|
committer | Wade Brainerd <wadetb@gmail.com> | 2008-11-21 16:48:13 (GMT) |
commit | afb05ac5b16412962103f9eaac9cd2ca44b80d1b (patch) | |
tree | 97c8e988cbc01f36bdbf079c9c0cc773b629d0de /typingturtle.py | |
parent | 35a5d25da9947c4a6e0ef4deeef3a82f5ec92077 (diff) |
Update WPM on timer.
Diffstat (limited to 'typingturtle.py')
-rwxr-xr-x | typingturtle.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/typingturtle.py b/typingturtle.py index b24e298..8a3fd37 100755 --- a/typingturtle.py +++ b/typingturtle.py @@ -132,6 +132,8 @@ class LessonScreen(gtk.VBox): #self.accuracyarea = gtk.DrawingArea() #self.accuracyarea.connect('expose-event', self.accuracy_expose_cb) + gobject.timeout_add(250, self.timer_cb) + hbox = gtk.HBox() hbox.pack_start(stopbtn, False, False, 10) hbox.pack_start(self.wpmlabel, True, False, 10) @@ -189,6 +191,9 @@ class LessonScreen(gtk.VBox): self.begin_lesson() def update_stats(self): + if not self.start_time or self.lesson_finished: + return + self.total_time = time.time() - self.start_time if self.total_time >= 1.0: self.wpm = 60 * (self.correct_keys / 5) / self.total_time @@ -198,7 +203,11 @@ class LessonScreen(gtk.VBox): self.accuracylabel.set_markup(_('<b>Accuracy:</b> %(accuracy)d%%') % { 'accuracy' : int(self.accuracy) } ) self.wpmlabel.set_markup(_('<b>WPM:</b> %(wpm)d') % { 'wpm': int(self.wpm) } ) - + + def timer_cb(self): + self.update_stats() + return True + def begin_lesson(self): self.lesson_finished = False @@ -241,6 +250,7 @@ class LessonScreen(gtk.VBox): # End lesson if this is the last step. if self.next_step_idx >= len(self.lesson['steps']): + print "Lesson finished." self.lesson_finished = True self.show_lesson_report() return @@ -461,7 +471,7 @@ class LessonScreen(gtk.VBox): # Upgrade the player's level if needed. if self.lesson['level'] > self.activity.data['level']: self.activity.data['level'] = self.lesson['level'] - self.activity.data['motd'] = _('You unlocked a new lesson!') + self.activity.data['motd'] = 'newlevel' self.activity.data['medals'][lesson_name] = medal self.activity.mainscreen.update_medals() @@ -652,7 +662,7 @@ class TypingTurtle(sugar.activity.activity.Activity): # All data which is saved in the Journal entry is placed in this dictionary. self.data = { - 'motd': _('Welcome to Typing Turtle!'), + 'motd': 'welcome', 'level': 0, 'history': [], 'medals': {} |