From 147ff80ae15d83b3df6b9a134ba3d9307d60d609 Mon Sep 17 00:00:00 2001 From: Walther Neuper Date: Tue, 15 Dec 2009 11:37:58 +0000 Subject: collect_table --> calc; switch exerc works partially --- diff --git a/ReckonPrimer.activity/coach.py b/ReckonPrimer.activity/coach.py index 1cb4234..ae86d12 100755 --- a/ReckonPrimer.activity/coach.py +++ b/ReckonPrimer.activity/coach.py @@ -30,9 +30,10 @@ class Coach: #print("in coach.notify: msg=, data=", (msg, data)) if msg == 'setting-done': # from display self._ex.update_setting(data) - self._learner.notify((msg, self._ex)) + self._learner.notify(('start-calcs', self._ex)) elif msg == 'exerc-selected': # from collection self._ex = self._collect.select(data) - #print('in coach.notify(exerc-selected), self._ex._sett=',self._ex._sett) - self._dis.offer_setting(self._ex) + print('in coach.notify(exerc-selected), _sett=',self._ex._sett) + #WN091215 self._dis.offer_setting(self._ex) + self._learner.notify(('start-calcs', self._ex)) diff --git a/ReckonPrimer.activity/collection.py b/ReckonPrimer.activity/collection.py index ea7ff39..8c49451 100644 --- a/ReckonPrimer.activity/collection.py +++ b/ReckonPrimer.activity/collection.py @@ -55,8 +55,8 @@ class Collection: TODO: define once at startup of RP ?""" #WN.LV diesen Code ersetzen: collection_table.attach(self.colldata,... self.topic_box = gtk.HBox(True, 0) - self._display.collection_table.attach(self.topic_box, 0, 6, 0, 1) - #self._display.collection_table.attach(self.topic_box, 0, 6, 5, 6) + #self._display.collection_table.attach(self.topic_box, 0, 6, 0, 1) + self._display.collection_table.attach(self.topic_box, 0, 6, 5, 6) def set_coll_gui(self, coll_data): """ Set gui-elements according to Collection.data. """ @@ -83,11 +83,12 @@ class Collection: def select_exerc_callback(self, widget, coll_key): """ Callback telling the item from the collection selected. """ #WN.LV diesen Code ersetzen> statt 1..n fuer Listen kommt coll_key + print('in Collection.select_exerc_callback') if(self._active_exerc == None): # at startup self._active_exerc = coll_key self._display.set_select_exerc_semaphore(coll_key) - self._coach.notify(('exerc-selected', coll_key)) + #self._coach.notify(('exerc-selected', coll_key)) elif(self._active_exerc == coll_key): # hit the same button once more pass @@ -96,5 +97,5 @@ class Collection: self._active_exerc = coll_key self._display.switch_exercise() # TODO rename self._display.set_select_exerc_semaphore(coll_key) - self._coach.notify(('exerc-selected', coll_key)) + #self._coach.notify(('exerc-selected', coll_key)) diff --git a/ReckonPrimer.activity/display.py b/ReckonPrimer.activity/display.py index 008d076..659036b 100755 --- a/ReckonPrimer.activity/display.py +++ b/ReckonPrimer.activity/display.py @@ -21,7 +21,8 @@ class Display: def __init__(self, window): self._permanent_gui_elements(window) self.errors = 0 - self._ex = None # WN091214 ??? + self._ex = None # needed for feedback_table etc + # TODO: imprive information hiding self._sett = None # setting updated by callbacks during input self.running = False # switch settings_/feedback_table TODO rename self._coll_key = None # semaphore for self.finish_collect_callback @@ -183,6 +184,18 @@ class Display: self.feedback_table.attach(self.progress_total, 5, 6, 9, 10 ) self.progress_total.show() + ### START BUTTON BEGIN ### + # works on feedback_+ settings_table: beware of show/hide/destroy them + self.start_button = gtk.Button(None, gtk.STOCK_GO_FORWARD) + self.start_button.connect("clicked", self.clicked_start_callback) + self.feedback_table.attach(self.start_button, 0, 6, 14, 15) + self.start_alignment = self.start_button.get_children()[0] + self.start_hbox = self.start_alignment.get_children()[0] + self.start_image, self.start_label = self.start_hbox.get_children() + self.start_label.set_label("") + self.start_button.show() + ### START BUTTON END ### + def feedback_table_hide(self): self.progressbar.set_fraction(0) self.stopwatch_label.hide() @@ -198,27 +211,13 @@ class Display: self._ex = ex #WN.LV either drop this or self.current_exercise self._sett = self._ex.get_setting() #WN.LV make _sett local - ### START BUTTON BEGIN ### - self.start_button = gtk.Button(None, gtk.STOCK_GO_FORWARD) - self.start_button.connect("clicked", self.clicked_start_callback) - self.feedback_table.attach(self.start_button, 0, 6, 14, 15) - self.start_alignment = self.start_button.get_children()[0] - self.start_hbox = self.start_alignment.get_children()[0] - self.start_image, self.start_label = self.start_hbox.get_children() - self.start_label.set_label("") - self.start_button.show() - ### START BUTTON END ### - self.current_exercise = ex #WN.LV either drop this or self._ex #print('in display.offer_setting, self._sett=', self._sett) self.current_exercise.define_buttons() self.current_exercise.set_buttons(self._sett) def clicked_start_callback(self, widget): - """ Finish offer_setting, deliver settings (possibly updated) - and tell the coach to start the calculations of the exercise - ELIF - """ + """ .start_button switches settings_ / feedback_table. """ if self.running == False: self.running = True self.start_button.set_label(gtk.STOCK_STOP) #stop-button @@ -382,16 +381,37 @@ class Display: def set_select_exerc_semaphore(self, coll_key): """ Sets a semaphore for finish_collect_callback. """ + print('in display.set_select_exerc_semaphore, coll_key', self._coll_key) self._coll_key = coll_key def set_finish_learner_coll(self): - """ """ -# self.start_button = gtk.Button(None, gtk.STOCK_GO_FORWARD) -# self.start_button.connect("clicked", self.clicked_start_callback) -# self.feedback_table.attach(self.start_button, 0, 6, 14, 15) -# self.start_alignment = self.start_button.get_children()[0] -# self.start_hbox = self.start_alignment.get_children()[0] -# self.start_image, self.start_label = self.start_hbox.get_children() -# self.start_label.set_label("") -# self.start_button.show() + """ Set the button switching from collect_table to calcs""" + print('in display.set_finish_learner_coll') + self.flc_butt = gtk.Button(None, gtk.STOCK_GO_FORWARD) + self.flc_butt.connect("clicked", self.finish_learner_coll_callback) + self.collection_table.attach(self.flc_butt, 0, 5, 14, 15) + self.flc_alignment = self.flc_butt.get_children()[0] + self.flc_hbox = self.flc_alignment.get_children()[0] + self.flc_image, self.flc_label = self.flc_hbox.get_children() + self.flc_label.set_label("") + self.flc_butt.show() pass + + def finish_learner_coll_callback(self, widget): + """ Callback on flc_butt; uses self._coll_key as semaphore + from Collection.select_exerc_callback. """ + #self.flc_butt.set_label(gtk.STOCK_STOP) #stop-button + #self.start_alignment = self.flc_butt.get_children()[0] + #self.start_hbox = self.start_alignment.get_children()[0] + #self.start_image, self.start_label = self.start_hbox.get_children() + #self.start_label.set_label("") + print('in display.finish_learner_coll_callback, _coll_key=', self._coll_key) + if not(self._coll_key is None): + self._co.notify(('exerc-selected', self._coll_key)) + #self.settings_table.hide() + self.collection_table.hide() + self.feedback_table_show() + + def set_curr_exerc(self, exerc): + """ self._ex is needed for feedback_table etc. """ + self._ex = exerc diff --git a/ReckonPrimer.activity/learner.py b/ReckonPrimer.activity/learner.py index f296983..fcbaf85 100644 --- a/ReckonPrimer.activity/learner.py +++ b/ReckonPrimer.activity/learner.py @@ -21,8 +21,9 @@ class Learner: def notify(self, (msg, data)): '''called by the observed objects''' #print('in learner.notify: msg=,data=', msg, data) - if msg == 'setting-done': # from Coach + 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) -- cgit v0.9.1