From 7fa4421c4b70c6988d0694c7416e68d89b03a48e Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Fri, 01 Oct 2010 16:54:02 +0000 Subject: propogate abacus value between abaci --- (limited to 'abacus_window.py') 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): -- cgit v0.9.1