[pygtk] Formatting floats in treeview
Jeremy S
dumbmatter at gmail.com
Wed Jun 18 15:02:52 WST 2008
If you put a float in a treeview, you get a really long decimal, which
is almost always not desired. So, after playing around with it for a
while, I came up with this code to truncate floats at 1 decimal place:
column.set_cell_data_func(renderer,
lambda column, cell, model, iter:
cell.set_property('text', '%.1f' % model.get_value(iter,
column.get_sort_column_id())))
The problem with this is that it uses
GtkTreeViewColumn::get_sort_column_id() to get the column number,
which only works if the column is sortable. Can anyone tell me what
to do if I want the formatting to work on any column, not just
sortable columns? Thank you.
More information about the pygtk
mailing list