Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AbacusActivity.py21
-rw-r--r--abacus_window.py32
2 files changed, 38 insertions, 15 deletions
diff --git a/AbacusActivity.py b/AbacusActivity.py
index 05ef248..fdef7cd 100644
--- a/AbacusActivity.py
+++ b/AbacusActivity.py
@@ -318,6 +318,7 @@ class AbacusActivity(activity.Activity):
def _custom_cb(self, button):
""" Display the custom abacus; hide the others """
+ value = float(self.abacus.mode.value(count_beads=False))
if self.abacus.custom is not None:
self.abacus.custom.hide()
self.abacus.custom = Custom(self.abacus,
@@ -327,20 +328,28 @@ class AbacusActivity(activity.Activity):
self._value_spin.get_value_as_int(),
self._base_spin.get_value_as_int())
self._select_abacus(None, None, self.abacus.custom)
+ self.abacus.mode.set_value_from_number(value)
+ self.abacus.mode.label(self.abacus.generate_label())
def _chinese_cb(self, button):
""" Display the suanpan; hide the others """
+ value = float(self.abacus.mode.value(count_beads=False))
if self.abacus.chinese is None:
self.abacus.chinese = Suanpan(self.abacus)
self._select_abacus(self.chinese, self.abacus.chinese.name+"-on",
self.abacus.chinese)
+ self.abacus.mode.set_value_from_number(value)
+ self.abacus.mode.label(self.abacus.generate_label())
def _japanese_cb(self, button):
+ value = float(self.abacus.mode.value(count_beads=False))
""" Display the soroban; hide the others """
if self.abacus.japanese is None:
self.abacus.japanese = Soroban(self.abacus)
self._select_abacus(self.japanese, self.abacus.japanese.name+"-on",
self.abacus.japanese)
+ self.abacus.mode.set_value_from_number(value)
+ self.abacus.mode.label(self.abacus.generate_label())
def _russian_cb(self, button):
""" Display the schety; hide the others """
@@ -350,32 +359,44 @@ class AbacusActivity(activity.Activity):
self.abacus.russian)
def _mayan_cb(self, button):
+ value = float(self.abacus.mode.value(count_beads=False))
""" Display the nepohualtzintzin; hide the others """
if self.abacus.mayan is None:
self.abacus.mayan = Nepohualtzintzin(self.abacus)
self._select_abacus(self.mayan, self.abacus.mayan.name+"-on",
self.abacus.mayan)
+ self.abacus.mode.set_value_from_number(value)
+ self.abacus.mode.label(self.abacus.generate_label())
def _binary_cb(self, button):
+ value = float(self.abacus.mode.value(count_beads=False))
""" Display the binary; hide the others """
if self.abacus.binary is None:
self.abacus.binary = Binary(self.abacus)
self._select_abacus(self.binary, self.abacus.binary.name+"-on",
self.abacus.binary)
+ self.abacus.mode.set_value_from_number(value)
+ self.abacus.mode.label(self.abacus.generate_label())
def _hex_cb(self, button):
+ value = float(self.abacus.mode.value(count_beads=False))
""" Display the hex; hide the others """
if self.abacus.hex is None:
self.abacus.hex = Hex(self.abacus)
self._select_abacus(self.hex, self.abacus.hex.name+"-on",
self.abacus.hex)
+ self.abacus.mode.set_value_from_number(value)
+ self.abacus.mode.label(self.abacus.generate_label())
def _decimal_cb(self, button):
+ value = float(self.abacus.mode.value(count_beads=False))
""" Display the decimal; hide the others """
if self.abacus.decimal is None:
self.abacus.decimal = Decimal(self.abacus)
self._select_abacus(self.decimal, self.abacus.decimal.name+"-on",
self.abacus.decimal)
+ self.abacus.mode.set_value_from_number(value)
+ self.abacus.mode.label(self.abacus.generate_label())
def _fraction_cb(self, button):
""" Display the fraction; hide the others """
diff --git a/abacus_window.py b/abacus_window.py
index 7e150f5..569eec0 100644
--- a/abacus_window.py
+++ b/abacus_window.py
@@ -757,23 +757,25 @@ class AbacusGeneric():
def value(self, count_beads=False):
""" Return a string representing the value of each rod. """
- string = ''
- v = []
- for r in range(self.num_rods+1): # +1 for overflow
- v.append(0)
-
- # Tally the values on each rod.
- for i, bead in enumerate(self.beads):
- r = i/(self.top_beads+self.bot_beads)
- j = i % (self.top_beads+self.bot_beads)
- if bead.get_state() == 1:
- if j < self.top_beads:
- v[r+1] += self.top_factor
- else:
- v[r+1] += 1
if count_beads:
# Save the value associated with each rod as a 2-byte integer.
+ string = ''
+ v = []
+ for r in range(self.num_rods+1): # +1 for overflow
+ v.append(0)
+
+ # Tally the values on each rod.
+ for i, bead in enumerate(self.beads):
+ r = i/(self.top_beads+self.bot_beads)
+ j = i % (self.top_beads+self.bot_beads)
+ if bead.get_state() == 1:
+ if j < self.top_beads:
+ v[r+1] += self.top_factor
+ else:
+ v[r+1] += 1
+
+ # Save the value associated with each rod as a 2-byte integer.
for j in v[1:]:
string += "%2d" % (j)
else:
@@ -781,7 +783,7 @@ class AbacusGeneric():
for bead in self.beads:
sum += bead.get_value()
string = str(sum)
-
+ print self.name, string
return(string)
def label(self, string):