Activities/Abacus: Difference between revisions
| Line 164: | Line 164: | ||
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. | 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 two modules: abacus.py and abacus_window.py. The former defines the menu to work from fedora; the latter defines what code is executed by each type of abacus. | Most changes can be confined to two modules: <code>abacus.py</code> and <code>abacus_window.py</code>. The former defines the menu to work from fedora; the latter defines what code is executed by each type of abacus. | ||
For instance, to add a menu item such as 'Reset' you would do the following in abacus.py: | For instance, to add a menu item such as 'Reset' you would do the following in <code>abacus.py</code>: | ||
(1) into the menu items list add | (1) into the menu items list add | ||
| Line 178: | Line 178: | ||
self.abacus.mode.reset_abacus() | self.abacus.mode.reset_abacus() | ||
This will complete the changes in the abacus.py. The method reset_abacus() will have to be defined for each abacus in the abacus_window.py. This can be done by creating that method in the | 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 Schety. | ||
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 | 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 Abacus</code>, method <code>_button_press_cb()</code> to activate reset button; | ||