electrum

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

commit 3cd088b2e6dcf1a46a47de72d39d466dcf5e6e87
parent 45618b2a8efedec84c9a92fbb92b070fae133a00
Author: ThomasV <thomasv@electrum.org>
Date:   Fri, 22 Jan 2016 10:50:24 +0100

kivy: fee_dialog

Diffstat:
Agui/kivy/uix/dialogs/fee_dialog.py | 48++++++++++++++++++++++++++++++++++++++++++++++++
Mgui/kivy/uix/dialogs/settings.py | 25++++++++++++++++++++++++-
2 files changed, 72 insertions(+), 1 deletion(-)

diff --git a/gui/kivy/uix/dialogs/fee_dialog.py b/gui/kivy/uix/dialogs/fee_dialog.py @@ -0,0 +1,48 @@ +from kivy.app import App +from kivy.factory import Factory +from kivy.properties import ObjectProperty +from kivy.lang import Builder + +Builder.load_string(''' +<FeeDialog@Popup> + id: popup + title: '' + size_hint: 0.8, 0.8 + pos_hint: {'top':0.9} + BoxLayout: + orientation: 'vertical' + BoxLayout: + orientation: 'horizontal' + size_hint: 1, 0.5 + Label: + text: _('Dynamic fees') + CheckBox: + id: dynfees + BoxLayout: + orientation: 'horizontal' + size_hint: 1, 0.5 + Button: + text: 'Cancel' + size_hint: 0.5, None + height: '48dp' + on_release: popup.dismiss() + Button: + text: 'OK' + size_hint: 0.5, None + height: '48dp' + on_release: + root.on_ok() + root.dismiss() +''') + +class FeeDialog(Factory.Popup): + + def __init__(self, config, callback): + Factory.Popup.__init__(self) + self.config = config + self.callback = callback + self.ids.dynfees.active = self.config.get('dynamic_fees') + + def on_ok(self): + self.config.set_key('dynamic_fees', self.ids.dynfees.active, True) + self.callback() diff --git a/gui/kivy/uix/dialogs/settings.py b/gui/kivy/uix/dialogs/settings.py @@ -7,6 +7,7 @@ from electrum.i18n import _ from electrum.util import base_units from electrum.i18n import languages, set_language from electrum.plugins import run_hook +from electrum.bitcoin import RECOMMENDED_FEE Builder.load_string(''' <SettingsItem@ButtonBehavior+BoxLayout> @@ -63,8 +64,14 @@ Builder.load_string(''' on_release: settings.unit_dialog(self) SettingsItem: + status: root.fee_status() + title: _('Fees') + ': ' + self.status + description: _("Fees paid to the Bitcoin miners.") + on_release: + root.fee_dialog(self) + SettingsItem: status: 'ON' if bool(app.plugins.get('exchange_rate')) else 'OFF' - title: _('Fiat Exchange rates') + ': ' + self.status + title: _('Exchange rates') + ': ' + self.status description: _("Display amounts in fiat currency.") on_release: settings.plugin_dialog('exchange_rate', self) @@ -175,9 +182,25 @@ class SettingsDialog(Factory.Popup): def callback(status): self.plugins.enable(name) if status else self.plugins.disable(name) label.status = 'ON' if status else 'OFF' + status = bool(self.plugins.get(name)) dd = self.plugins.descriptions.get(name) descr = dd.get('description') fullname = dd.get('fullname') d = CheckBoxDialog(fullname, descr, status, callback) d.open() + + def fee_status(self): + if self.config.get('dynamic_fees'): + f = self.config.get('fee_factor', 50) + 50 + return 'Dynamic, %d%%'%f + else: + F = self.config.get('fee_per_kb', RECOMMENDED_FEE) + return self.app.format_amount(F) + ' ' + self.app.base_unit + '/kB' + + def fee_dialog(self, label): + from fee_dialog import FeeDialog + def cb(): + label.status = self.fee_status() + d = FeeDialog(self.config, cb) + d.open()