From a97a0629dd3d22afe98cb3d68a6ed0fa0eca7170 Mon Sep 17 00:00:00 2001 From: slush0 Date: Mon, 30 Jun 2014 16:40:11 +0200 Subject: [PATCH] Added base unit 'bits'. --- gui/qt/amountedit.py | 10 ++++++++-- gui/qt/main_window.py | 22 +++++++++++++++++----- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/gui/qt/amountedit.py b/gui/qt/amountedit.py index 49561ad..c1fb082 100644 --- a/gui/qt/amountedit.py +++ b/gui/qt/amountedit.py @@ -63,8 +63,14 @@ class BTCAmountEdit(AmountEdit): def _base_unit(self): p = self.decimal_point() - assert p in [5,8] - return "BTC" if p == 8 else "mBTC" + assert p in [2, 5, 8] + if p == 8: + return 'BTC' + if p == 5: + return 'mBTC' + if p == 2: + return 'bits' + raise Exception('Unknown base unit') def get_amount(self): try: diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py index e3990b7..3cf27d0 100644 --- a/gui/qt/main_window.py +++ b/gui/qt/main_window.py @@ -444,9 +444,14 @@ class ElectrumWindow(QMainWindow): def base_unit(self): - assert self.decimal_point in [5,8] - return "BTC" if self.decimal_point == 8 else "mBTC" - + assert self.decimal_point in [2, 5, 8] + if self.decimal_point == 2: + return 'bits' + if self.decimal_point == 5: + return 'mBTC' + if self.decimal_point == 8: + return 'BTC' + raise Exception('Unknown base unit') def update_status(self): if self.network is None or not self.network.is_running(): @@ -2486,7 +2491,7 @@ class ElectrumWindow(QMainWindow): if not self.config.is_modifiable('fee_per_kb'): for w in [fee_e, fee_label]: w.setEnabled(False) - units = ['BTC', 'mBTC'] + units = ['BTC', 'mBTC', 'bits'] unit_label = QLabel(_('Base unit') + ':') grid.addWidget(unit_label, 3, 0) unit_combo = QComboBox() @@ -2557,7 +2562,14 @@ class ElectrumWindow(QMainWindow): unit_result = units[unit_combo.currentIndex()] if self.base_unit() != unit_result: - self.decimal_point = 8 if unit_result == 'BTC' else 5 + if unit_result == 'BTC': + self.decimal_point = 8 + elif unit_result == 'mBTC': + self.decimal_point = 5 + elif unit_result == 'bits': + self.decimal_point = 2 + else: + raise Exception('Unknown base unit') self.config.set_key('decimal_point', self.decimal_point, True) self.update_history_tab() self.update_status() -- 1.7.1