tkivy: button that rotates base_unit - electrum - Electrum Bitcoin wallet (HTM) git clone https://git.parazyd.org/electrum (DIR) Log (DIR) Files (DIR) Refs (DIR) Submodules --- (DIR) commit 59948d725c243dd6fd289561ada9ec23c587ed7b (DIR) parent 069a6455c7ba909bdf216bdcb29c8ec5ff9d2fbe (HTM) Author: ThomasV <thomasv@electrum.org> Date: Thu, 15 Oct 2015 11:35:32 +0200 kivy: button that rotates base_unit Diffstat: M gui/kivy/main_window.py | 6 +++++- M gui/kivy/uix/ui_screens/settings.kv | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) --- (DIR) diff --git a/gui/kivy/main_window.py b/gui/kivy/main_window.py t@@ -52,6 +52,8 @@ base_units = {'BTC':8, 'mBTC':5, 'uBTC':2} class ElectrumWindow(App): + electrum_config = ObjectProperty(None) + def _get_bu(self): return self.electrum_config.get('base_unit', 'mBTC') t@@ -64,7 +66,9 @@ class ElectrumWindow(App): base_unit = AliasProperty(_get_bu, _set_bu) - electrum_config = ObjectProperty(None) + def _rotate_bu(self): + keys = sorted(base_units.keys()) + self.base_unit = keys[ (keys.index(self.base_unit) + 1) % len(keys)] status = StringProperty(_('Not Connected')) (DIR) diff --git a/gui/kivy/uix/ui_screens/settings.kv b/gui/kivy/uix/ui_screens/settings.kv t@@ -13,13 +13,13 @@ Popup: text: _('Base unit') height: '48dp' size_hint: 1, None - Spinner: + Button: text: app.base_unit - values: ('BTC', 'mBTC') size_hint: 1, None height: '48dp' - on_text: app.base_unit = self.text - + on_release: + app._rotate_bu() + self.text = app.base_unit Label: size_hint: 1, None text: 'OpenAlias'