electrum

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

commit e46b00bb39a8f3b324a72d6fc4f7015a9cff4402
parent f7a3b53c3fc200f675abe0475197011e9b805c8d
Author: ThomasV <thomasv@electrum.org>
Date:   Fri, 18 Dec 2015 13:04:19 +0100

move methods related to amount dialog

Diffstat:
Mgui/kivy/main.kv | 6------
Mgui/kivy/main_window.py | 22----------------------
Mgui/kivy/uix/dialogs/amount_dialog.py | 36++++++++++++++++++++++++++++++++----
Mgui/kivy/uix/ui_screens/receive.kv | 7++++---
4 files changed, 36 insertions(+), 35 deletions(-)

diff --git a/gui/kivy/main.kv b/gui/kivy/main.kv @@ -243,12 +243,6 @@ background_active: 'atlas://gui/kivy/theming/light/textinput_active' -<KButton@Button>: - size_hint: 1, None - height: '48dp' - on_release: - self.parent.update_text(self.parent, self.text) - <TabbedPanelStrip>: on_parent: diff --git a/gui/kivy/main_window.py b/gui/kivy/main_window.py @@ -491,28 +491,6 @@ class ElectrumWindow(App): text += c label.password = text - def toggle_fiat(self, a): - a.is_fiat = not a.is_fiat - - def update_amount(self, label, c): - amount = label.fiat_amount if label.is_fiat else label.amount - if c == '<': - amount = amount[:-1] - elif c == '.' and amount == '': - amount = '0.' - elif c == '0' and amount == '0': - amount = '0' - else: - try: - Decimal(amount+c) - amount += c - except: - pass - - if label.is_fiat: - label.fiat_amount = amount - else: - label.amount = amount def format_amount(self, x, is_diff=False, whitespaces=False): return format_satoshis(x, is_diff, 0, self.decimal_point(), whitespaces) diff --git a/gui/kivy/uix/dialogs/amount_dialog.py b/gui/kivy/uix/dialogs/amount_dialog.py @@ -2,9 +2,15 @@ from kivy.app import App from kivy.factory import Factory from kivy.properties import ObjectProperty from kivy.lang import Builder - +from decimal import Decimal Builder.load_string(''' +<KButton@Button>: + size_hint: 1, None + height: '48dp' + on_release: + self.parent.update_amount(self.text) + <AmountDialog@Popup> id: popup title: _('Amount') @@ -32,8 +38,8 @@ Builder.load_string(''' is_fiat: False on_fiat_amount: if self.is_fiat: self.amount = app.fiat_to_btc(self.fiat_amount) on_amount: if not self.is_fiat: self.fiat_amount = app.btc_to_fiat(self.amount) - update_text: app.update_amount size_hint: 1, None + update_amount: popup.update_amount height: '300dp' cols: 3 KButton: @@ -76,7 +82,7 @@ Builder.load_string(''' height: '48dp' text: (app.fiat_unit if kb.is_fiat else app.base_unit) if app.fiat_unit else '' on_release: - app.toggle_fiat(kb) + popup.toggle_fiat(kb) Button: size_hint: 1, None height: '48dp' @@ -90,7 +96,7 @@ Builder.load_string(''' size_hint: 1, None height: '48dp' Widget: - size_hint: 2, None + size_hint: 1, None height: '48dp' Button: size_hint: 1, None @@ -112,3 +118,25 @@ class AmountDialog(Factory.Popup): if amount: self.ids.kb.amount = amount + def toggle_fiat(self, a): + a.is_fiat = not a.is_fiat + + def update_amount(self, c): + kb = self.ids.kb + amount = kb.fiat_amount if kb.is_fiat else kb.amount + if c == '<': + amount = amount[:-1] + elif c == '.' and amount in ['0', '']: + amount = '0.' + elif amount == '0': + amount = c + else: + try: + Decimal(amount+c) + amount += c + except: + pass + if kb.is_fiat: + kb.fiat_amount = amount + else: + kb.amount = amount diff --git a/gui/kivy/uix/ui_screens/receive.kv b/gui/kivy/uix/ui_screens/receive.kv @@ -42,7 +42,8 @@ ReceiveScreen: size_hint: 1, None height: '48dp' opacity: 0.5 if qr.shaded else 1 - text: s.address + text: _('Bitcoin Address') + ': ' + s.address + text_size: self.width, None SendReceiveBlueBottom: id: blue_bottom @@ -98,5 +99,5 @@ ReceiveScreen: size_hint: 1, None height: '48dp' on_release: s.parent.do_new() - Widget: - size_hint: 1, 0.3 + #Widget: + # size_hint: 1, 0.3