Skip to content

Commit

Permalink
improvve fake floats representations (#29)
Browse files Browse the repository at this point in the history
* improvve fake floats representations

values like 123.0 should be represetented as 123

* its already a float
  • Loading branch information
typemytype authored Apr 10, 2019
1 parent 945e126 commit 6dab10d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions Lib/defconAppKit/controls/fontInfoView.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,15 @@ def _numberToString(self, value):
if self._allowFloat:
if not float(value).is_integer():
return self._floatFormat % value
return str(value)
return "%i" % value

def _stringToNumber(self, string):
value = None
newString = string
try:
value = self._numberClass(string)
if self._allowFloat and value.is_integer():
value = int(value)
if value < 0 and not self._allowNegative:
newString = self._previousString
value, n = self._stringToNumber(newString)
Expand Down Expand Up @@ -185,10 +187,7 @@ def set(self, value):
if value == "":
value = None
if isinstance(value, basestring):
if self._allowFloat:
value = float(value)
else:
value = int(value)
value = self._numberClass(value)
if value is not None:
value = self._numberToString(value)
super(NumberEditText, self).set(value)
Expand Down

0 comments on commit 6dab10d

Please sign in to comment.