align decimal point in columns

This commit is contained in:
ThomasV 2011-12-09 20:41:21 +01:00
parent ce6363a754
commit 84d774e269
1 changed files with 7 additions and 6 deletions

View File

@ -29,12 +29,11 @@ gtk.gdk.threads_init()
APP_NAME = "Electrum" APP_NAME = "Electrum"
def format_satoshis(x): def format_satoshis(x):
xx = str( Decimal(x) /100000000 ) s = str( Decimal(x) /100000000 )
#xx = ("%f"%(x*1e-8)).rstrip('0') if not '.' in s: s += '.'
if not '.' in xx: xx = xx + '.' p = s.find('.')
if len(xx) > 0 and xx[-1] =='.': xx+="00" s += " "*( 8 - ( len(s) - p ))
if len(xx) > 1 and xx[-2] =='.': xx+="0" return s
return xx
def numbify(entry, is_int = False): def numbify(entry, is_int = False):
text = entry.get_text().strip() text = entry.get_text().strip()
@ -737,6 +736,7 @@ class BitcoinGUI:
treeview.append_column(tvcolumn) treeview.append_column(tvcolumn)
cell = gtk.CellRendererText() cell = gtk.CellRendererText()
cell.set_alignment(1, 0.5) cell.set_alignment(1, 0.5)
cell.set_property('family', 'monospace')
tvcolumn.pack_start(cell, False) tvcolumn.pack_start(cell, False)
tvcolumn.add_attribute(cell, 'text', 5) tvcolumn.add_attribute(cell, 'text', 5)
@ -744,6 +744,7 @@ class BitcoinGUI:
treeview.append_column(tvcolumn) treeview.append_column(tvcolumn)
cell = gtk.CellRendererText() cell = gtk.CellRendererText()
cell.set_alignment(1, 0.5) cell.set_alignment(1, 0.5)
cell.set_property('family', 'monospace')
tvcolumn.pack_start(cell, False) tvcolumn.pack_start(cell, False)
tvcolumn.add_attribute(cell, 'text', 6) tvcolumn.add_attribute(cell, 'text', 6)