diff options
author | Walther Neuper <neuper@neuper.(none)> | 2009-12-12 12:22:46 (GMT) |
---|---|---|
committer | Walther Neuper <neuper@neuper.(none)> | 2009-12-12 12:22:46 (GMT) |
commit | 5b909158c3d2631429f2e4ed5ff5a253023ec7e0 (patch) | |
tree | 4c2d7e2ef8d0375247ea4466e5bac3756278720a | |
parent | d8d0a422b572595b12eeef449d9df1f13599acd3 (diff) |
changed notify'digit-done'','setting-done'
-rwxr-xr-x | ReckonPrimer.activity/coach.py | 5 | ||||
-rwxr-xr-x | ReckonPrimer.activity/display.py | 5 | ||||
-rw-r--r-- | ReckonPrimer.activity/learner.py | 38 | ||||
-rwxr-xr-x | ReckonPrimer.activity/session.py | 72 |
4 files changed, 80 insertions, 40 deletions
diff --git a/ReckonPrimer.activity/coach.py b/ReckonPrimer.activity/coach.py index 50bf484..078c767 100755 --- a/ReckonPrimer.activity/coach.py +++ b/ReckonPrimer.activity/coach.py @@ -27,9 +27,10 @@ class Coach: # self._exs = self.create_exs() self._ex = None - def register(self, sess, dis): + def register(self, sess, dis, learner): self._sess = sess self._dis = dis + self._learner = learner def create_exercises(self): self._exs = self.create_exs() @@ -87,7 +88,7 @@ class Coach: # + self._setts.save_last_sett(self._key, data) self._ex.update_setting(data) self._update_exs(self._ex) - self._sess.notify((msg, self._ex)) + self._learner.notify((msg, self._ex)) elif msg == 'new-topic': self._ex = self.get_ex(data) print('in Coach.notify(new-topic), 93 self._ex._sett=', diff --git a/ReckonPrimer.activity/display.py b/ReckonPrimer.activity/display.py index d8be96c..b3c2dfe 100755 --- a/ReckonPrimer.activity/display.py +++ b/ReckonPrimer.activity/display.py @@ -121,10 +121,11 @@ class Display: # Display the table self.table.show() - def register(self, sess, co): + def register(self, sess, co, learner): """register _after_ Session and Coach have been instantiated""" self._sess = sess self._co = co + self._learner = learner def update_time(self): minutes, seconds = divmod(self.stopwatch.elapsed, 60) @@ -380,7 +381,7 @@ class Display: def notify(self, msg): """only used by gtk""" if msg[0] == 'digit-done': - self._sess.notify(('digit-done', None)) + self._learner.notify(('digit-done', None)) def show_progress(self): self.progressbar.set_fraction(self.progressbar.get_fraction()+(float(1)/float(self.total_calcs))) diff --git a/ReckonPrimer.activity/learner.py b/ReckonPrimer.activity/learner.py index 355f5cc..6ca42bb 100644 --- a/ReckonPrimer.activity/learner.py +++ b/ReckonPrimer.activity/learner.py @@ -6,6 +6,10 @@ class Learner: def __init__(self, display, coach): self._display = display self._coach = coach + self._ex = None + self._calcs = None # TODO rm after _generate_calcs --> get_next_calc + self._key = None + self._curr_in = None # TODO rm ??? pass def run(self): @@ -16,3 +20,37 @@ 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 Session.notify: msg=,data=', msg, data) + if msg == 'setting-done': # from Coach + self._ex = data + self._calcs = data._generate_calcs() # TODO rm + self._key = data.get_topic() + (self._calcs).reverse() # TODO rm + _calc = (self._calcs).pop() + #print('in Session.notify: calc=', _calc) + _lines, self._input = data.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 + if msg == 'digit-done': # from Display + #print('in Session.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)) + if len(self._input) > 0: + self._curr_in = self._input.pop() + self._display.create_entryline(self._curr_in) + else: # start new calc + self._display.show_progress() + if len(self._calcs) > 0: + _calc = (self._calcs).pop() + print('in Session.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 + else: + self._display.finish_calc() diff --git a/ReckonPrimer.activity/session.py b/ReckonPrimer.activity/session.py index 99aba78..813e9ba 100755 --- a/ReckonPrimer.activity/session.py +++ b/ReckonPrimer.activity/session.py @@ -16,10 +16,10 @@ class Session: self._name = name self._dis = Display(window) self._co = Coach() - self._co.register(self, self._dis) - self._dis.register(self, self._co) self._learner = Learner(self._dis, self._co) self._author = Author() + self._co.register(self, self._dis, self._learner) + self._dis.register(self, self._co, self._learner) self._co.create_exercises() #TODO.WN091101 replace by storing Exerc.s self._calcs = None #pop ! @@ -36,37 +36,37 @@ class Session: #self._co.request_exercise() #self._dis.init_calc() #TODOWN091101 take Exercise as argument - def notify(self, (msg, data)): - '''called by the observed objects''' - #print('in Session.notify: msg=,data=', msg, data) - if msg == 'setting-done': # from Coach - self._ex = data - self._calcs = data._generate_calcs() - self._key = data.get_topic() - (self._calcs).reverse() - _calc = (self._calcs).pop() - #print('in Session.notify: calc=', _calc) - _lines, self._input = data.format(_calc) - self._dis.display_calc(_lines) - self._curr_in = self._input.pop() #need _curr_in in notify - self._dis.create_entryline(self._curr_in) - # create_entryline sets the callback from gtk to Display - if msg == 'digit-done': # from Display - #print('in Session.notify, digit-done: _input=', self._input) - (lino, pos, dig, proterr, protok, li) = self._curr_in - self._dis.create_entryline((lino, -1, dig, proterr, protok, li)) - if len(self._input) > 0: - self._curr_in = self._input.pop() - self._dis.create_entryline(self._curr_in) - else: # start new calc - self._dis.show_progress() - if len(self._calcs) > 0: - _calc = (self._calcs).pop() - print('in Session.notify: calc=', _calc) - _lines, self._input = self._ex.format(_calc) - self._dis.display_calc(_lines) - self._curr_in = self._input.pop() #need _curr_in in notify - self._dis.create_entryline(self._curr_in) - # create_entryline sets the callback from gtk to Display - else: - self._dis.finish_calc() +# def notify(self, (msg, data)): +# '''called by the observed objects''' +# #print('in Session.notify: msg=,data=', msg, data) +# if msg == 'setting-done': # from Coach +# self._ex = data +# self._calcs = data._generate_calcs() +# self._key = data.get_topic() +# (self._calcs).reverse() +# _calc = (self._calcs).pop() +# #print('in Session.notify: calc=', _calc) +# _lines, self._input = data.format(_calc) +# self._dis.display_calc(_lines) +# self._curr_in = self._input.pop() #need _curr_in in notify +# self._dis.create_entryline(self._curr_in) +# # create_entryline sets the callback from gtk to Display +# if msg == 'digit-done': # from Display +# #print('in Session.notify, digit-done: _input=', self._input) +# (lino, pos, dig, proterr, protok, li) = self._curr_in +# self._dis.create_entryline((lino, -1, dig, proterr, protok, li)) +# if len(self._input) > 0: +# self._curr_in = self._input.pop() +# self._dis.create_entryline(self._curr_in) +# else: # start new calc +# self._dis.show_progress() +# if len(self._calcs) > 0: +# _calc = (self._calcs).pop() +# print('in Session.notify: calc=', _calc) +# _lines, self._input = self._ex.format(_calc) +# self._dis.display_calc(_lines) +# self._curr_in = self._input.pop() #need _curr_in in notify +# self._dis.create_entryline(self._curr_in) +# # create_entryline sets the callback from gtk to Display +# else: +# self._dis.finish_calc() |