Line 8: |
Line 8: |
| | | |
| [[File:Abacus.jpg]] | | [[File:Abacus.jpg]] |
| + | |
| + | [[File:Abacus-activity.png]] |
| | | |
| == Where to get Abacus == | | == Where to get Abacus == |
Line 123: |
Line 125: |
| File:Abacus-fractions.png|20 + 1 + 1/2 + 1/3 + 1/6 = 22 | | File:Abacus-fractions.png|20 + 1 + 1/2 + 1/3 + 1/6 = 22 |
| </gallery> | | </gallery> |
− |
| |
− | == Modifying Abacus ==
| |
− | Abacus is under GPL license. You are free to use it and learn with it. You are also encouraged to modify it to suit your needs or just for a further opportunity to learn.
| |
− |
| |
− | Most changes can be confined to three modules: <code>AbacusActivity.py</code>, <code>abacus.py</code> and <code>abacus_window.py</code>. The former define the Sugar and GNOME toolbars; the latter defines what code is executed by each type of abacus.
| |
− |
| |
− | '''Note: since a recent refactoring, these instructions are deprecated'''
| |
− |
| |
− | For instance, to add a menu item such as 'Reset' you would do the following in <code>abacus.py</code>:
| |
− |
| |
− | * Add these lines to the menu items list:
| |
− | menu_items = gtk.MenuItem(_("Reset"))
| |
− | menu.append(menu_items)
| |
− | menu_items.connect("activate", self._reset)
| |
− |
| |
− | * The _reset() method is trivial:
| |
− | def _reset(self, event, data=None):
| |
− | """ Reset """
| |
− | self.abacus.mode.reset_abacus()
| |
− |
| |
− | Similarly, you can add another button to the Sugar toolbar in <code>AbacusActivity.py</code>:
| |
− |
| |
− | * Add these lines to the toolbar block:
| |
− | # Reset the beads on the abacus to the initial cleared position
| |
− | self.reset_button = ToolButton( "reset" )
| |
− | self.reset_button.set_tooltip(_('Reset'))
| |
− | self.reset_button.props.sensitive = True
| |
− | self.reset_button.connect('clicked', self._reset_button_cb)
| |
− | toolbar_box.toolbar.insert(self.reset_button, -1)
| |
− | self.reset_button.show()
| |
− |
| |
− | * The _reset_button_cb() method is trivial:
| |
− | def _reset_button_cb(self, event, data=None):
| |
− | """ Reset the beads on the abacus to the initial cleared position """
| |
− | self.abacus.mode.reset_abacus()
| |
− |
| |
− | * You'll have to create an icon for the button (<code>reset.svg</code>) and put it into the <code>icon</code> subdirectory of the bundle.
| |
− |
| |
− | This will complete the changes in the <code>abacus.py</code>. The method <code>reset_abacus()</code> will have to be defined for each abacus in the <code>abacus_window.py</code>. This can be done by creating that method in the <code>AbacusGeneric</code> class used by all the varieties of abacus. The method may have to be overridden in some abacus subclasses for customization reasons. For instance, <code>reset_abacus()</code> was defined in <code>AbacusGeneric</code> class and then overridden in <code>Schety</code>.
| |
− |
| |
− | If the changes involve modifying the graphics, then other methods may need to be modified as well. For instance, in order to introduce a reset button that can be clicked to reset the bead positions to the beginning, the following methods had to be modified – all in <code>abacus_window.py</code>:
| |
− |
| |
− | # in the <code>class Abacus</code>, method <code>_button_press_cb()</code> to activate reset button;
| |
− | # in the <code>class AbacusGeneric</code>, method <code>create()</code> to create the graphics for reset button;
| |
− | # methods <code>hide()</code> and <code>show()</code> to make the button visible.
| |
| | | |
| === The toolbars === | | === The toolbars === |
Line 249: |
Line 206: |
| * Abacus also supports copy, so you can take a sum calculated on an abacus and export it into SimpleGraph or some other data-visualization Activities. | | * Abacus also supports copy, so you can take a sum calculated on an abacus and export it into SimpleGraph or some other data-visualization Activities. |
| | | |
| + | == Modifying Abacus == |
| + | Abacus is under GPL license. You are free to use it and learn with it. You are also encouraged to modify it to suit your needs or just for a further opportunity to learn. |
| + | |
| + | Most changes can be confined to three modules: <code>AbacusActivity.py</code>, <code>abacus.py</code> and <code>abacus_window.py</code>. The former define the Sugar and GNOME toolbars; the latter defines what code is executed by each type of abacus. |
| + | |
| + | '''Note: since a recent refactoring, these instructions are deprecated''' |
| + | |
| + | For instance, to add a menu item such as 'Reset' you would do the following in <code>abacus.py</code>: |
| + | |
| + | * Add these lines to the menu items list: |
| + | menu_items = gtk.MenuItem(_("Reset")) |
| + | menu.append(menu_items) |
| + | menu_items.connect("activate", self._reset) |
| + | |
| + | * The _reset() method is trivial: |
| + | def _reset(self, event, data=None): |
| + | """ Reset """ |
| + | self.abacus.mode.reset_abacus() |
| + | |
| + | Similarly, you can add another button to the Sugar toolbar in <code>AbacusActivity.py</code>: |
| + | |
| + | * Add these lines to the toolbar block: |
| + | # Reset the beads on the abacus to the initial cleared position |
| + | self.reset_button = ToolButton( "reset" ) |
| + | self.reset_button.set_tooltip(_('Reset')) |
| + | self.reset_button.props.sensitive = True |
| + | self.reset_button.connect('clicked', self._reset_button_cb) |
| + | toolbar_box.toolbar.insert(self.reset_button, -1) |
| + | self.reset_button.show() |
| + | |
| + | * The _reset_button_cb() method is trivial: |
| + | def _reset_button_cb(self, event, data=None): |
| + | """ Reset the beads on the abacus to the initial cleared position """ |
| + | self.abacus.mode.reset_abacus() |
| + | |
| + | * You'll have to create an icon for the button (<code>reset.svg</code>) and put it into the <code>icon</code> subdirectory of the bundle. |
| + | |
| + | This will complete the changes in the <code>abacus.py</code>. The method <code>reset_abacus()</code> will have to be defined for each abacus in the <code>abacus_window.py</code>. This can be done by creating that method in the <code>AbacusGeneric</code> class used by all the varieties of abacus. The method may have to be overridden in some abacus subclasses for customization reasons. For instance, <code>reset_abacus()</code> was defined in <code>AbacusGeneric</code> class and then overridden in <code>Schety</code>. |
| + | |
| + | If the changes involve modifying the graphics, then other methods may need to be modified as well. For instance, in order to introduce a reset button that can be clicked to reset the bead positions to the beginning, the following methods had to be modified – all in <code>abacus_window.py</code>: |
| + | |
| + | # in the <code>class Abacus</code>, method <code>_button_press_cb()</code> to activate reset button; |
| + | # in the <code>class AbacusGeneric</code>, method <code>create()</code> to create the graphics for reset button; |
| + | # methods <code>hide()</code> and <code>show()</code> to make the button visible. |
| | | |
| == Reporting problems == | | == Reporting problems == |