On 26-02-11 21:13, Johann Schatzer wrote:
Using TreeStore with "float" column, e.g.
self.treestore = gtk.TreeStore(float)

the widget shows floating point numbers with a precision of 6 digits, like 
34.234566 or 22.000000

How can you get a precision of only 1 or 2 digits, like 34.23 or 22.0 ?

I would like to know the same. Here is a simple testcase which demonstrates the problem.

Cheers,
Timo

import gtk

MYFLOAT = 12.3456

def main():
    win = gtk.Window()
    win.resize(300, 200)
    win.connect('delete-event', gtk.main_quit)

    liststore = gtk.ListStore(float, float)
    treeview = gtk.TreeView(liststore)
    renderer = gtk.CellRendererText()
    col = gtk.TreeViewColumn("Actual", renderer, text=0)
    treeview.append_column(col)
    col = gtk.TreeViewColumn("Rounded", renderer, text=1)
    treeview.append_column(col)

    liststore.append([MYFLOAT, round(MYFLOAT, 2)])

    win.add(treeview)
    win.show_all()
    gtk.main()

if __name__ == '__main__':
    main()
_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to