electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 9b2885e697008445ba4a929d18bdf1d476a9cfc4
parent 84b18e0949055e6e668f27e95d307bba137f4544
Author: ThomasV <thomasv@electrum.org>
Date:   Sat,  5 Dec 2015 18:14:17 +0100

kivy: updates

Diffstat:
Mgui/kivy/main_window.py | 18++++++++++--------
Mgui/kivy/uix/ui_screens/amount.kv | 6++++--
Mplugins/exchange_rate/exchange_rate.py | 1+
Mplugins/exchange_rate/kivy.py | 4++++
4 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/gui/kivy/main_window.py b/gui/kivy/main_window.py @@ -95,18 +95,20 @@ class ElectrumWindow(App): def btc_to_fiat(self, amount_str): if not amount_str: return '' - satoshis = self.get_amount(amount_str + ' ' + self.base_unit) - fiat_text = run_hook('format_amount_and_units', satoshis) - return fiat_text if fiat_text else '' + rate = run_hook('exchange_rate') + if not rate: + return '' + fiat_amount = self.get_amount(amount_str + ' ' + self.base_unit) * rate / pow(10, 8) + return "{:.2f}".format(fiat_amount).rstrip('0').rstrip('.') + ' ' + self.fiat_unit def fiat_to_btc(self, fiat_amount): if not fiat_amount: return '' - satoshis = pow(10, 8) - x = run_hook('format_amount_and_units', satoshis) - rate, unit = x.split() - amount = satoshis * Decimal(fiat_amount) / Decimal(rate) - return format_satoshis_plain(amount, self.decimal_point()) + ' ' + self.base_unit + rate = run_hook('exchange_rate') + if not rate: + return '' + satoshis = int(pow(10,8) * Decimal(fiat_amount) / Decimal(rate)) + return format_satoshis_plain(satoshis, self.decimal_point()) + ' ' + self.base_unit def get_amount(self, amount_str): a, u = amount_str.split() diff --git a/gui/kivy/uix/ui_screens/amount.kv b/gui/kivy/uix/ui_screens/amount.kv @@ -72,12 +72,14 @@ Popup: size_hint: 1, None height: '48dp' text: 'Max' - on_release: a.amount = app.get_max_amount() + on_release: + a.is_fiat = False + a.amount = app.get_max_amount() Button: id: button_fiat size_hint: 1, None height: '48dp' - text: '/' + text: app.fiat_unit if a.is_fiat else app.base_unit on_release: app.toggle_fiat(a) Button: diff --git a/plugins/exchange_rate/exchange_rate.py b/plugins/exchange_rate/exchange_rate.py @@ -309,6 +309,7 @@ class FxPlugin(BasePlugin, ThreadJob): def on_history(self): pass + @hook def exchange_rate(self): '''Returns None, or the exchange rate as a Decimal''' rate = self.exchange.quotes.get(self.ccy) diff --git a/plugins/exchange_rate/kivy.py b/plugins/exchange_rate/kivy.py @@ -9,3 +9,7 @@ class Plugin(FxPlugin): def on_quotes(self): self.print_error("on quotes", self.ccy) self.window.fiat_unit = self.ccy + + def on_history(self): + self.print_error("on history") + self.window.history_screen.update()