numbify
This commit is contained in:
parent
9325f47543
commit
ff0dee2964
|
@ -38,14 +38,23 @@ def format_satoshis(x):
|
||||||
|
|
||||||
def numbify(entry, is_int = False):
|
def numbify(entry, is_int = False):
|
||||||
text = entry.get_text().strip()
|
text = entry.get_text().strip()
|
||||||
s = ''.join([i for i in text if i in '0123456789.'])
|
chars = '0123456789'
|
||||||
|
if not is_int: chars +='.'
|
||||||
|
s = ''.join([i for i in text if i in chars])
|
||||||
if not is_int:
|
if not is_int:
|
||||||
p = s.find(".")
|
if '.' in s:
|
||||||
s = s[:p+9]
|
p = s.find('.')
|
||||||
|
s = s.replace('.','')
|
||||||
|
s = s[:p] + '.' + s[p:p+8]
|
||||||
try:
|
try:
|
||||||
amount = int( Decimal(s) * 100000000 )
|
amount = int( Decimal(s) * 100000000 )
|
||||||
except:
|
except:
|
||||||
amount = None
|
amount = None
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
amount = int( s )
|
||||||
|
except:
|
||||||
|
amount = None
|
||||||
entry.set_text(s)
|
entry.set_text(s)
|
||||||
return amount
|
return amount
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue