Exemple #1
0
 def testFractToFloat(self):
     for s, n in [
         ('1', 1),
         ('123', 123),
         ('1 1/2', 1.5),
         ('74 2/5', 74.4),
         ('1/10', 0.1),
         ('one', 1),
         ('a half', 0.5),
         ('three quarters', 0.75),
     ]:
         self.assertEqual(convert.frac_to_float(s), n)
Exemple #2
0
 def testFractToFloat (self):
     for s,n in [
         ('1',1),
         ('123',123),
         ('1 1/2',1.5),
         ('74 2/5',74.4),
         ('1/10',0.1),
         ('one',1),
         ('a half',0.5),
         ('three quarters',0.75),
         ]:
         self.assertEqual(convert.frac_to_float(s),n)
 def changed (self, *args):
     amt1 = convert.frac_to_float(self.amt1Entry.get_text())
     #amt2 = convert.frac_to_float(self.resultLabel.get_text())
     #amt2 = self.amt2
     unit1 = cb_get_active_text(self.unit1ComboBox)
     unit2 = cb_get_active_text(self.unit2ComboBox)
     if unit1 != self.last_unit1:
         self.get_possible_conversions()
     #self.unit2Model.refilter()
     if amt1 and unit2:
         self.convert(amt1, unit1, unit2)
     self.last_amt1 = amt1
     #self.last_amt2 = amt2
     self.last_unit1 = unit1
     self.last_unit2 = unit2