From 284bcc1e5bb4725ca0404944779b9e83d709f217 Mon Sep 17 00:00:00 2001 From: Darrin Daigle Date: Sun, 23 Mar 2014 23:17:20 -0500 Subject: [PATCH] better handling of very small fiat numbers and mBTC --- plugins/exchange_rate.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/plugins/exchange_rate.py b/plugins/exchange_rate.py index 06a5822a..a43e699d 100644 --- a/plugins/exchange_rate.py +++ b/plugins/exchange_rate.py @@ -563,17 +563,19 @@ class Plugin(BasePlugin): if not d.exec_(): return - fiat = self.gui.main_window.read_amount(str(fiat_e.text())) + fiat = str(fiat_e.text()) - if str(fiat) == "None" or str(fiat) == "0": - self.gui.main_window.amount_e.setText( "" ) - return + if str(fiat) == "" or str(fiat) == ".": + fiat = "0" r = {} self.set_quote_text(100000000, r) quote = r.get(0) quote = quote[:-4] - quote = str(Decimal(fiat) / (Decimal(quote)*100000000)) + btcamount = Decimal(fiat) / Decimal(quote) + if str(self.gui.main_window.base_unit()) == "mBTC": + btcamount = btcamount * 1000 + quote = "%.8f"%btcamount if quote: self.gui.main_window.amount_e.setText( quote )