diff options
Diffstat (limited to 'ReckonPrimer.activity/learner.py')
-rw-r--r-- | ReckonPrimer.activity/learner.py | 55 |
1 files changed, 26 insertions, 29 deletions
diff --git a/ReckonPrimer.activity/learner.py b/ReckonPrimer.activity/learner.py index fcbaf85..5df67e2 100644 --- a/ReckonPrimer.activity/learner.py +++ b/ReckonPrimer.activity/learner.py @@ -18,34 +18,31 @@ class Learner: self._coach.request_exercise() self._display.init_calc() #TODOWN091101 take Exercise as argument - def notify(self, (msg, data)): - '''called by the observed objects''' - #print('in learner.notify: msg=,data=', msg, data) - if msg == 'start-calcs': # from Coach - self._ex = data - self._display.set_curr_exerc(data) - _calc = self._ex.get_next_calc() - _lines, self._input = data.format(_calc) - self._display.display_calc(_lines) - self._curr_in = self._input.pop() #need _curr_in in notify + def start_calcs(self, exercise): + self._ex = exercise + self._display.set_curr_exerc(exercise) + _calc = self._ex.get_next_calc() + _lines, self._input = exercise.format(_calc) + self._display.display_calc(_lines) + self._curr_in = self._input.pop() #need _curr_in in notify + self._display.create_entryline(self._curr_in) + + def digit_done(self): + (lino, pos, dig, proterr, protok, li) = self._curr_in + self._display.create_entryline((lino, -1, dig, proterr, protok, li)) + try: # _input.pop() + self._curr_in = self._input.pop() self._display.create_entryline(self._curr_in) - # create_entryline sets the callback from gtk to display - if msg == 'digit-done': # from Display - #print('in learner.notify, digit-done: _input=', self._input) - (lino, pos, dig, proterr, protok, li) = self._curr_in - self._display.create_entryline((lino, -1, dig, proterr, protok, li)) - try: # _input.pop() - self._curr_in = self._input.pop() + except IndexError: # start new calc + self._display.show_progress() + try: # get_next_calc + _calc = self._ex.get_next_calc() + print('in learner.notify: calc=', _calc) + _lines, self._input = self._ex.format(_calc) + self._display.display_calc(_lines) + self._curr_in = self._input.pop() #need _curr_in in notify self._display.create_entryline(self._curr_in) - except IndexError: # start new calc - self._display.show_progress() - try: # get_next_calc - _calc = self._ex.get_next_calc() - print('in learner.notify: calc=', _calc) - _lines, self._input = self._ex.format(_calc) - self._display.display_calc(_lines) - self._curr_in = self._input.pop() #need _curr_in in notify - self._display.create_entryline(self._curr_in) - # create_entryline sets the callback from gtk to Display - except IndexError: - self._display.finish_calc() + # create_entryline sets the callback from gtk to Display + except IndexError: + self._display.finish_calc() +
\ No newline at end of file |