From e83045fa53d23f5e4c08d1514260842635398005 Mon Sep 17 00:00:00 2001 From: Walther Neuper Date: Sun, 10 Jan 2010 13:33:23 +0000 Subject: Merge branch 'master' of git://git.sugarlabs.org/rp/mifixs-clone into mayer --- diff --git a/ReckonPrimer.activity/ReckonPrimerActivity.py b/ReckonPrimer.activity/ReckonPrimerActivity.py index 45ae36d..813a838 100755 --- a/ReckonPrimer.activity/ReckonPrimerActivity.py +++ b/ReckonPrimer.activity/ReckonPrimerActivity.py @@ -3,20 +3,21 @@ from time import strftime import pygtk import gtk + from sugar.activity import activity from sugar.datastore import datastore from sugar import profile from session import Session +from toolbar import Toolbar class ReckonPrimerActivity(activity.Activity): def __init__(self, handle): activity.Activity.__init__(self, handle) - """ Create the official Sugar toolbox at the top of the screen""" - toolbox = activity.ActivityToolbox(self) - self.set_toolbox(toolbox) - toolbox.show() + + toolbar = Toolbar(self) + toolbar.show() file_location = activity.get_activity_root() + \ "/data/reckonprimer_report.txt" diff --git a/ReckonPrimer.activity/coach.py b/ReckonPrimer.activity/coach.py index 3406c08..57f95bd 100755 --- a/ReckonPrimer.activity/coach.py +++ b/ReckonPrimer.activity/coach.py @@ -31,19 +31,14 @@ class Coach: self._dis.offer_coll_to_learner(self._collect) # calls back with notify('exerc-selected'... OR 'switch-to-setts' - def notify(self, (msg, data)): - """called by the observed objects""" - print("in coach.notify: msg=, data=", (msg, data)) - if msg == 'setting-done': # from display - self._ex.update_setting(data) - 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), _sett=',self._ex._sett) - self._learner.notify(('start-calcs', self._ex)) - elif msg == 'switch-to-setts': # from display - self._ex = self._collect.select(data) - self._dis.offer_setting(self._ex) - else: - raise Error() - + def exercise_selected(self, key): + self._ex = self._collect.select(key) + self._learner.start_calcs(self._ex) + + def switch_to_settings(self, key): + self._ex = self._collect.select(key) + self._dis.offer_setting(self._ex) + + def settings_done(self, settings): + self._ex.update_setting(settings) + self._learner.start_calcs(self._ex) diff --git a/ReckonPrimer.activity/collection.py b/ReckonPrimer.activity/collection.py index 53ababe..4a45bd1 100644 --- a/ReckonPrimer.activity/collection.py +++ b/ReckonPrimer.activity/collection.py @@ -10,12 +10,9 @@ from sugar.graphics import style from settings import Settings from coach import Coach -from exaddsimp import ExAddSimp -from exaddsub import ExAddSub -from expassten import ExPassTen -from exmult import ExMult -from extimesdiv import ExTimesDiv -from extimesadd import ExTimesAdd +from exercises import * +from exercises.exercise import Exercise + class Collection: @@ -31,24 +28,20 @@ class Collection: self._active_exerc = None def select(self, key): - """ Select an exercise by key. + """ Select an exercise by key. return instance of an exercise. Errors are retrieved for (future) use by Coach. """ #WN.LV Code ersetzen: key ist dann fuer Listen von Listen !! (_sett, _errors) = self._data[key] - if _sett['topic'] == 'addsub_simp': - return ExAddSimp(self._display, (_sett, _errors)) - elif _sett['topic'] == 'exaddsub': - return ExAddSub(self._display, (_sett, _errors)) - elif _sett['topic'] == 'passten': - return ExPassTen(self._display, (_sett, _errors)) - elif _sett['topic'] == 'exmult': - return ExMult(self._display, (_sett, _errors)) - elif _sett['topic'] == 'times_div': - return ExTimesDiv(self._display, (_sett, _errors)) - elif _sett['topic'] == 'extimesadd': - return ExTimesAdd(self._display, (_sett, _errors)) - else: - raise Exception() + exercise_label = _sett['topic'] + + if not Exercise.EXERCISES.has_key(exercise_label): + raise Exception('Collection#select: Wrong key. To register an exercise see exercises/__init__.py') + + klass = Exercise.EXERCISES[exercise_label] + package = __import__("exercises." + klass) + module = getattr(package, klass) + return getattr(module, klass)(self._display, (_sett, _errors)) + def define_coll_gui(self): """ Define gui-elements for presenting the collection. diff --git a/ReckonPrimer.activity/display.py b/ReckonPrimer.activity/display.py index 3554b33..92fc7ee 100755 --- a/ReckonPrimer.activity/display.py +++ b/ReckonPrimer.activity/display.py @@ -257,7 +257,7 @@ class Display: def release_sett_callback(self, widget): """ Start calcs with these settings (probably updated). """ print('in display.release_sett_callback') - self._co.notify(('setting-done', self._ex._sett)) + self._co.settings_done(self._ex._sett) self.settings_table.hide() #self.collection_table.hide() self.feedback_table_show() @@ -299,7 +299,7 @@ class Display: self.errors = 0 #WN090518 ??? self.protocol(protok, self.errors, 'OK') self.destroy_box() - self.notify(('digit-done', None)) + self._learner.digit_done() elif(entry_text == ""): pass #otherwise feedback in protocol written twice: see entry.set_text("") below else: @@ -360,12 +360,6 @@ class Display: def finish_calc(self): self.stopwatch.stop() - - def notify(self, msg): - """only used by gtk""" - if msg[0] == 'digit-done': - self._learner.notify(('digit-done', None)) - def show_progress(self): self.progressbar.set_fraction(self.progressbar.get_fraction()+(float(1)/float(self.total_calcs))) self.correct_count = self.correct_count + 1 @@ -421,13 +415,13 @@ class Display: from Collection.select_exerc_callback. """ 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._co.exercise_selected(self._coll_key) self.collection_table.hide() self.feedback_table_show() def switch_learner_to_setts(self, widget): """ Callback on sts_butt. asks the Coach if allowed. """ - self._co.notify(('switch-to-setts', self._coll_key)) + self._co.switch_to_settings(self._coll_key) self.collection_table.hide() def set_curr_exerc(self, exerc): diff --git a/ReckonPrimer.activity/exercises/__init__.py b/ReckonPrimer.activity/exercises/__init__.py new file mode 100644 index 0000000..461e7d2 --- /dev/null +++ b/ReckonPrimer.activity/exercises/__init__.py @@ -0,0 +1,16 @@ +""" To register a new Exercise, append module name to EXERCISES """ + +from exercise import Exercise + + +""" TODO naming convention for 'topic' (aka exercise name) """ + +Exercise.EXERCISES = { 'addsub_simp': "ExAddSimp", \ + 'exaddsub': "ExAddSub", \ + 'exmult': "ExMult", \ + 'passten': "ExPassTen", \ + 'extimesadd': "ExTimesAdd", \ + 'times_div': "ExTimesDiv" } + + +__all__ = Exercise.EXERCISES.values() diff --git a/ReckonPrimer.activity/exaddsimp.py b/ReckonPrimer.activity/exercises/exaddsimp.py index aa1dd42..aa1dd42 100755 --- a/ReckonPrimer.activity/exaddsimp.py +++ b/ReckonPrimer.activity/exercises/exaddsimp.py diff --git a/ReckonPrimer.activity/exaddsub.py b/ReckonPrimer.activity/exercises/exaddsub.py index ed3d8d9..ed3d8d9 100644 --- a/ReckonPrimer.activity/exaddsub.py +++ b/ReckonPrimer.activity/exercises/exaddsub.py diff --git a/ReckonPrimer.activity/exercise.py b/ReckonPrimer.activity/exercises/exercise.py index 09d83ce..3049a4e 100755 --- a/ReckonPrimer.activity/exercise.py +++ b/ReckonPrimer.activity/exercises/exercise.py @@ -3,6 +3,9 @@ from functions import contain, collect_digits, make_line, make_input from functions import make_line_remainder, make_input_remainder class Exercise: + + EXERCISES = {} + """This is the base class for the individual exercises. An exercise is characterized by a topic. A topic determines the fields of the settings self._sett and public methods of Exercise. diff --git a/ReckonPrimer.activity/exmult.py b/ReckonPrimer.activity/exercises/exmult.py index fb6452f..fb6452f 100644 --- a/ReckonPrimer.activity/exmult.py +++ b/ReckonPrimer.activity/exercises/exmult.py diff --git a/ReckonPrimer.activity/expassten.py b/ReckonPrimer.activity/exercises/expassten.py index b177cfa..6bac2f3 100755 --- a/ReckonPrimer.activity/expassten.py +++ b/ReckonPrimer.activity/exercises/expassten.py @@ -225,109 +225,109 @@ class ExPassTen(Exercise): def define_buttons(self): """ See comment in Exercies.define_buttons. """ - self.toggle_plus = gtk.ToggleButton("+") - self.toggle_label = self.toggle_plus.get_child() - self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12))) - self.toggle_plus.connect("toggled", self.toggle_plus_callback) - self._display.settings_table.attach(self.toggle_plus, 1, 2, 10, 11 ) - self.toggle_plus.show() - - self.toggle_minus = gtk.ToggleButton("-") - self.toggle_label = self.toggle_minus.get_child() - self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12))) - self.toggle_minus.connect("toggled", self.toggle_minus_callback) - self._display.settings_table.attach(self.toggle_minus, 1, 2, 9, 10 ) + self.toggle_plus = gtk.ToggleButton("+") + self.toggle_label = self.toggle_plus.get_child() + self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12))) + self.toggle_plus.connect("toggled", self.toggle_plus_callback) + self._display.settings_table.attach(self.toggle_plus, 1, 2, 10, 11 ) + self.toggle_plus.show() + + self.toggle_minus = gtk.ToggleButton("-") + self.toggle_label = self.toggle_minus.get_child() + self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12))) + self.toggle_minus.connect("toggled", self.toggle_minus_callback) + self._display.settings_table.attach(self.toggle_minus, 1, 2, 9, 10 ) self.toggle_minus.show() - self.label0 = gtk.Label("3") - self.label0.modify_font(pango.FontDescription("sans 12")) - self._display.settings_table.attach(self.label0, 2, 3, 10, 11 ) + self.label0 = gtk.Label("3") + self.label0.modify_font(pango.FontDescription("sans 12")) + self._display.settings_table.attach(self.label0, 2, 3, 10, 11 ) self.label0.show() - self.label1 = gtk.Label("=") - self.label1.modify_font(pango.FontDescription("sans 12")) - self._display.settings_table.attach(self.label1, 3, 4, 10, 11 ) + self.label1 = gtk.Label("=") + self.label1.modify_font(pango.FontDescription("sans 12")) + self._display.settings_table.attach(self.label1, 3, 4, 10, 11 ) self.label1.show() - self.label2 = gtk.Label("12") - self.label2.modify_font(pango.FontDescription("sans 12")) - self._display.settings_table.attach(self.label2, 4, 5, 10, 11 ) + self.label2 = gtk.Label("12") + self.label2.modify_font(pango.FontDescription("sans 12")) + self._display.settings_table.attach(self.label2, 4, 5, 10, 11 ) self.label2.show() - self.label3 = gtk.Label("1 + 2") - self.label3.modify_font(pango.FontDescription("sans 12")) - self._display.settings_table.attach(self.label3, 2, 3, 11, 12 ) + self.label3 = gtk.Label("1 + 2") + self.label3.modify_font(pango.FontDescription("sans 12")) + self._display.settings_table.attach(self.label3, 2, 3, 11, 12 ) self.label3.show() - self.label6 = gtk.Label(self._display._sett['MAX']) - self.label6.modify_font(pango.FontDescription("sans 12")) - self._display.settings_table.attach(self.label6, 5, 6, 1, 2 ) + self.label6 = gtk.Label(self._display._sett['MAX']) + self.label6.modify_font(pango.FontDescription("sans 12")) + self._display.settings_table.attach(self.label6, 5, 6, 1, 2 ) self.label6.show() - #self.label7 = gtk.Label(self._display._sess._gen.count((self._display._key, self._display._sett))) - #self.label7.modify_font(pango.FontDescription("sans 12")) - #self._display.settings_table.attach(self.label7, 5, 6, 2, 3 ) + #self.label7 = gtk.Label(self._display._sess._gen.count((self._display._key, self._display._sett))) + #self.label7.modify_font(pango.FontDescription("sans 12")) + #self._display.settings_table.attach(self.label7, 5, 6, 2, 3 ) #self.label7.show() - self.toggle_newline = gtk.ToggleButton("<") - self.toggle_label = self.toggle_newline.get_child() - self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12))) - self.toggle_newline.connect("toggled", self.toggle_newline_callback) - self._display.settings_table.attach(self.toggle_newline, 5, 6, 11, 12) + self.toggle_newline = gtk.ToggleButton("<") + self.toggle_label = self.toggle_newline.get_child() + self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12))) + self.toggle_newline.connect("toggled", self.toggle_newline_callback) + self._display.settings_table.attach(self.toggle_newline, 5, 6, 11, 12) self.toggle_newline.show() - self.toggle_shuffle_all = gtk.ToggleButton("@") - self.toggle_shuffle_all_label = self.toggle_shuffle_all.get_child() - self.toggle_shuffle_all_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12))) - self.toggle_shuffle_all.connect("toggled", self.toggle_shuffle_all_callback) - self._display.settings_table.attach(self.toggle_shuffle_all, 0, 1, 13, 14 ) + self.toggle_shuffle_all = gtk.ToggleButton("@") + self.toggle_shuffle_all_label = self.toggle_shuffle_all.get_child() + self.toggle_shuffle_all_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12))) + self.toggle_shuffle_all.connect("toggled", self.toggle_shuffle_all_callback) + self._display.settings_table.attach(self.toggle_shuffle_all, 0, 1, 13, 14 ) self.toggle_shuffle_all.show() - self.toggle_shuffle_inner = gtk.ToggleButton("@") - self.toggle_shuffle_inner_label = self.toggle_shuffle_inner.get_child() - self.toggle_shuffle_inner_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12))) - self.toggle_shuffle_inner.connect("toggled", self.toggle_shuffle_inner_callback) - self._display.settings_table.attach(self.toggle_shuffle_inner, 2, 3, 13, 14 ) - self.toggle_shuffle_inner.show() - - self.toggle_pos3 = gtk.ToggleButton("--") - self.toggle_label = self.toggle_pos3.get_child() - self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12))) - self.toggle_pos3.connect("toggled", self.toggle_pos3_callback) - self._display.settings_table.attach(self.toggle_pos3, 2, 3, 12, 13 ) - self.toggle_pos3.show() - - self.toggle_pos5 = gtk.ToggleButton("--") - self.toggle_label = self.toggle_pos5.get_child() - self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12))) - self.toggle_pos5.connect("toggled", self.toggle_pos5_callback) - self._display.settings_table.attach(self.toggle_pos5, 4, 5, 12, 13 ) + self.toggle_shuffle_inner = gtk.ToggleButton("@") + self.toggle_shuffle_inner_label = self.toggle_shuffle_inner.get_child() + self.toggle_shuffle_inner_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12))) + self.toggle_shuffle_inner.connect("toggled", self.toggle_shuffle_inner_callback) + self._display.settings_table.attach(self.toggle_shuffle_inner, 2, 3, 13, 14 ) + self.toggle_shuffle_inner.show() + + self.toggle_pos3 = gtk.ToggleButton("--") + self.toggle_label = self.toggle_pos3.get_child() + self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12))) + self.toggle_pos3.connect("toggled", self.toggle_pos3_callback) + self._display.settings_table.attach(self.toggle_pos3, 2, 3, 12, 13 ) + self.toggle_pos3.show() + + self.toggle_pos5 = gtk.ToggleButton("--") + self.toggle_label = self.toggle_pos5.get_child() + self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12))) + self.toggle_pos5.connect("toggled", self.toggle_pos5_callback) + self._display.settings_table.attach(self.toggle_pos5, 4, 5, 12, 13 ) self.toggle_pos5.show() - self.number_butts = [] - - for i in range(1,9+1): - self.toggle = gtk.ToggleButton(str(i)) - self.toggle_label = self.toggle.get_child() - self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12))) - self.toggle.connect("toggled", self.toggle_number_callback, i) - self._display.settings_table.attach(self.toggle, 0, 1, 1+i, 2+i) - self.toggle.show() + self.number_butts = [] + + for i in range(1,9+1): + self.toggle = gtk.ToggleButton(str(i)) + self.toggle_label = self.toggle.get_child() + self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12))) + self.toggle.connect("toggled", self.toggle_number_callback, i) + self._display.settings_table.attach(self.toggle, 0, 1, 1+i, 2+i) + self.toggle.show() self.number_butts.append(self.toggle) def set_buttons(self, sett): """ See comment in Exercies.set_buttons. """ - for i in range(sett['min'],sett['max']+1): + for i in range(sett['min'],sett['max']+1): self.number_butts[i-1].set_active(True) - - if (sett['+'] == True): - self.toggle_plus.set_active(True) - else: - self.toggle_plus.set_active(False) - - if (sett['-'] == True): - self.toggle_minus.set_active(True) - else: + + if (sett['+'] == True): + self.toggle_plus.set_active(True) + else: + self.toggle_plus.set_active(False) + + if (sett['-'] == True): + self.toggle_minus.set_active(True) + else: self.toggle_minus.set_active(False) if (sett['newline'] == True): @@ -345,34 +345,34 @@ class ExPassTen(Exercise): else: self.toggle_shuffle_inner.set_active(False) - for i in sett['input']: - if( i == 1 ): - self.toggle_pos1.set_active(True) - - if ( i == 3 ): - self.toggle_pos3.set_active(True) - - if ( i == 5 ): + for i in sett['input']: + if( i == 1 ): + self.toggle_pos1.set_active(True) + + if ( i == 3 ): + self.toggle_pos3.set_active(True) + + if ( i == 5 ): self.toggle_pos5.set_active(True) #**** callbacks ******************************************************** def toggle_newline_callback(self, widget): - if widget.get_active(): + if widget.get_active(): self._display._sett['newline'] = True else: self._display._sett['newline'] = False def toggle_shuffle_all_callback(self, widget): - if widget.get_active(): + if widget.get_active(): self._display._sett['shuffle_all'] = True self.toggle_shuffle_inner.set_active(True) else: self._display._sett['shuffle_all'] = False def toggle_shuffle_inner_callback(self, widget): - if widget.get_active(): + if widget.get_active(): self._display._sett['shuffle_inner'] = True else: if(self.toggle_shuffle_all.get_active()): @@ -381,7 +381,7 @@ class ExPassTen(Exercise): self._display._sett['shuffle_inner'] = False def toggle_pos3_callback(self, widget): - if widget.get_active(): + if widget.get_active(): self._display._sett['input'] = list(set(self._display._sett['input']) | set([3])) else: if(self.toggle_pos5.get_active()): @@ -390,31 +390,31 @@ class ExPassTen(Exercise): widget.set_active(True) def toggle_pos5_callback(self, widget): - if widget.get_active(): - self._display._sett['input'] = list(set(self._display._sett['input']) | set([5])) + if widget.get_active(): + self._display._sett['input'] = list(set(self._display._sett['input']) | set([5])) else: if(self.toggle_pos3.get_active()): self._display._sett['input'] = list(set(self._display._sett['input']) - set([5])) else: widget.set_active(True) - def toggle_plus_callback(self, widget): - if widget.get_active(): - self._display._sett['+'] = True - - else: - if( self.toggle_minus.get_active() ): - self._display._sett['+'] = False - else: - widget.set_active(True) - - def toggle_minus_callback(self, widget): - if widget.get_active(): - self._display._sett['-'] = True - else: - if( self.toggle_plus.get_active() ): - self._display._sett['-'] = False - else: + def toggle_plus_callback(self, widget): + if widget.get_active(): + self._display._sett['+'] = True + + else: + if( self.toggle_minus.get_active() ): + self._display._sett['+'] = False + else: + widget.set_active(True) + + def toggle_minus_callback(self, widget): + if widget.get_active(): + self._display._sett['-'] = True + else: + if( self.toggle_plus.get_active() ): + self._display._sett['-'] = False + else: widget.set_active(True) def toggle_number_callback(self, widget, i): diff --git a/ReckonPrimer.activity/extimesadd.py b/ReckonPrimer.activity/exercises/extimesadd.py index 060375b..060375b 100644 --- a/ReckonPrimer.activity/extimesadd.py +++ b/ReckonPrimer.activity/exercises/extimesadd.py diff --git a/ReckonPrimer.activity/extimesdiv.py b/ReckonPrimer.activity/exercises/extimesdiv.py index d1fe8a0..d1fe8a0 100755 --- a/ReckonPrimer.activity/extimesdiv.py +++ b/ReckonPrimer.activity/exercises/extimesdiv.py 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 diff --git a/ReckonPrimer.activity/toolbar.py b/ReckonPrimer.activity/toolbar.py new file mode 100644 index 0000000..e243a05 --- /dev/null +++ b/ReckonPrimer.activity/toolbar.py @@ -0,0 +1,41 @@ +import gtk + +from sugar.activity.widgets import ActivityToolbarButton +from sugar.activity.widgets import StopButton +from sugar.graphics.toolbutton import ToolButton +from sugar.graphics.toolbarbox import ToolbarButton, ToolbarBox + +class Toolbar: + + def __init__(self, parent): + self._parent = parent + + def show(self): + toolbar_box = ToolbarBox() + + activity_button = ActivityToolbarButton(self._parent) + toolbar_box.toolbar.insert(activity_button, 0) + + separator = gtk.SeparatorToolItem() + separator.show() + toolbar_box.toolbar.insert(separator, -1) + + learner_button = ToolButton() + learner_button.set_tooltip('Learner') + toolbar_box.toolbar.insert(learner_button, -1) + + authour_button = ToolButton() + authour_button.set_tooltip('Author') + toolbar_box.toolbar.insert(authour_button, -1) + + separator = gtk.SeparatorToolItem() + separator.props.draw = False + separator.set_expand(True) + separator.show() + toolbar_box.toolbar.insert(separator, -1) + + stop = StopButton(self._parent) + toolbar_box.toolbar.insert(stop, -1) + + toolbar_box.show_all() + self._parent.set_toolbar_box(toolbar_box) \ No newline at end of file -- cgit v0.9.1