Browse Source

whitespaces option in format_satoshis

283
ThomasV 12 years ago
parent
commit
d2b86091b4
  1. 8
      gui/gui_classic.py
  2. 4
      gui/gui_gtk.py
  3. 2
      gui/gui_text.py
  4. 3
      lib/util.py

8
gui/gui_classic.py

@ -505,8 +505,8 @@ class ElectrumWindow(QMainWindow):
self.need_update.clear() self.need_update.clear()
self.run_hook('timer_actions') self.run_hook('timer_actions')
def format_amount(self, x, is_diff=False): def format_amount(self, x, is_diff=False, whitespaces=False):
return format_satoshis(x, is_diff, self.wallet.num_zeros, self.decimal_point) return format_satoshis(x, is_diff, self.wallet.num_zeros, self.decimal_point, whitespaces)
def read_amount(self, x): def read_amount(self, x):
if x in['.', '']: return None if x in['.', '']: return None
@ -720,11 +720,11 @@ class ElectrumWindow(QMainWindow):
icon = QIcon(":icons/confirmed.png") icon = QIcon(":icons/confirmed.png")
if value is not None: if value is not None:
v_str = self.format_amount(value, True) v_str = self.format_amount(value, True, whitespaces=True)
else: else:
v_str = '--' v_str = '--'
balance_str = self.format_amount(balance) balance_str = self.format_amount(balance, whitespaces=True)
if tx_hash: if tx_hash:
label, is_default_label = self.wallet.get_label(tx_hash) label, is_default_label = self.wallet.get_label(tx_hash)

4
gui/gui_gtk.py

@ -1183,8 +1183,8 @@ class ElectrumWindow:
details = self.get_tx_details(tx_hash) details = self.get_tx_details(tx_hash)
self.history_list.prepend( [tx_hash, conf_icon, time_str, label, is_default_label, self.history_list.prepend( [tx_hash, conf_icon, time_str, label, is_default_label,
format_satoshis(value,True,self.wallet.num_zeros), format_satoshis(value,True,self.wallet.num_zeros, whitespaces=True),
format_satoshis(balance,False,self.wallet.num_zeros), tooltip, details] ) format_satoshis(balance,False,self.wallet.num_zeros, whitespaces=True), tooltip, details] )
if cursor: self.history_treeview.set_cursor( cursor ) if cursor: self.history_treeview.set_cursor( cursor )

2
gui/gui_text.py

@ -79,7 +79,7 @@ class ElectrumGui:
time_str = 'pending' time_str = 'pending'
label, is_default_label = self.wallet.get_label(tx_hash) label, is_default_label = self.wallet.get_label(tx_hash)
messages.append( format_str%( time_str, label, format_satoshis(value), format_satoshis(balance) ) ) messages.append( format_str%( time_str, label, format_satoshis(value, whitespaces=True), format_satoshis(balance, whitespaces=True) ) )
self.print_list(messages[::-1], format_str%( _("Date"), _("Description"), _("Amount"), _("Balance"))) self.print_list(messages[::-1], format_str%( _("Date"), _("Description"), _("Amount"), _("Balance")))

3
lib/util.py

@ -79,7 +79,7 @@ def local_data_dir():
return local_data return local_data
def format_satoshis(x, is_diff=False, num_zeros = 0, decimal_point = 8): def format_satoshis(x, is_diff=False, num_zeros = 0, decimal_point = 8, whitespaces=False):
from decimal import Decimal from decimal import Decimal
s = Decimal(x) s = Decimal(x)
sign, digits, exp = s.as_tuple() sign, digits, exp = s.as_tuple()
@ -95,6 +95,7 @@ def format_satoshis(x, is_diff=False, num_zeros = 0, decimal_point = 8):
p = s.find('.') p = s.find('.')
s += "0"*( 1 + num_zeros - ( len(s) - p )) s += "0"*( 1 + num_zeros - ( len(s) - p ))
if whitespaces:
s += " "*( 1 + decimal_point - ( len(s) - p )) s += " "*( 1 + decimal_point - ( len(s) - p ))
s = " "*( 13 - decimal_point - ( p )) + s s = " "*( 13 - decimal_point - ( p )) + s
return s return s

Loading…
Cancel
Save