tkivy: minor fixes related to exchange rates - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit c9b0840c7879db73a5fed5fb4ab0b4b086d905d4 DIR parent c3ff6040d25eb58a874aac2ff4355292843daec3 HTML Author: ThomasV <thomasv@electrum.org> Date: Sun, 4 Mar 2018 23:58:38 +0100 kivy: minor fixes related to exchange rates Diffstat: M gui/kivy/main_window.py | 6 ++++-- M gui/kivy/uix/dialogs/amount_dialog… | 1 + M gui/kivy/uix/dialogs/fx_dialog.py | 2 ++ M gui/kivy/uix/screens.py | 2 ++ M gui/kivy/uix/ui_screens/history.kv | 2 +- 5 files changed, 10 insertions(+), 3 deletions(-) --- DIR diff --git a/gui/kivy/main_window.py b/gui/kivy/main_window.py t@@ -179,8 +179,10 @@ class ElectrumWindow(App): def btc_to_fiat(self, amount_str): if not amount_str: return '' + if not self.fx.is_enabled(): + return '' rate = self.fx.exchange_rate() - if not rate: + if rate.is_nan(): return '' fiat_amount = self.get_amount(amount_str + ' ' + self.base_unit) * rate / pow(10, 8) return "{:.2f}".format(fiat_amount).rstrip('0').rstrip('.') t@@ -189,7 +191,7 @@ class ElectrumWindow(App): if not fiat_amount: return '' rate = self.fx.exchange_rate() - if not rate: + if rate.is_nan(): return '' satoshis = int(pow(10,8) * Decimal(fiat_amount) / Decimal(rate)) return format_satoshis_plain(satoshis, self.decimal_point()) DIR diff --git a/gui/kivy/uix/dialogs/amount_dialog.py b/gui/kivy/uix/dialogs/amount_dialog.py t@@ -39,6 +39,7 @@ Builder.load_string(''' size_hint: 1, None font_size: '20dp' height: '48dp' + disabled: not app.fx.is_enabled() on_release: kb.is_fiat = True Widget: DIR diff --git a/gui/kivy/uix/dialogs/fx_dialog.py b/gui/kivy/uix/dialogs/fx_dialog.py t@@ -106,4 +106,6 @@ class FxDialog(Factory.Popup): if ccy != self.fx.get_currency(): self.fx.set_currency(ccy) self.app.fiat_unit = ccy + else: + self.app.is_fiat = False Clock.schedule_once(lambda dt: self.add_exchanges()) DIR diff --git a/gui/kivy/uix/screens.py b/gui/kivy/uix/screens.py t@@ -373,6 +373,8 @@ class ReceiveScreen(CScreen): def save_request(self): addr = self.screen.address + if not addr: + return amount = self.screen.amount message = self.screen.message amount = self.app.get_amount(amount) if amount else 0 DIR diff --git a/gui/kivy/uix/ui_screens/history.kv b/gui/kivy/uix/ui_screens/history.kv t@@ -63,7 +63,7 @@ HistoryScreen: font_size: '30dp' bold: True size_hint: 1, 0.25 - on_release: app.is_fiat = not app.is_fiat + on_release: app.is_fiat = not app.is_fiat if app.fx.is_enabled() else False ScrollView: id: content do_scroll_x: False