On Tue, Nov 11, 2008 at 01:51:26PM +0100, Alessandro Dentella wrote:
> 
> Hi,
> 
>   I want to add support for localization to my package sqlkit[1], for text,
>   numbers and dates.
> 
>   I'm unsure on what kind of support PyGTK gives. 

I give some more details: 

spin button
===========
if I use spin button, depending on the locale in use I can get the decimal
separator "." or ",".

I don't know how to get a thousand separator. Is it possible?

TreeModel
==========

the attached example shows that if I use:

   * model with gobject.TYPE_FLOAT
   * CellRendererText
   * column.add_attribute(self.cell, 'text', 0 )

I get decimal separator correctly (but again no thousand separator)

If I use 

   * model with 'object'  type (the obly way I foound to allow me to set
     NULL values, ie: None)
   
   OR

   * set_cell_data_func


I can't even get the decimal separator correct.



I couldn't find other support for localization provided by PyGTK. Is this
correct?



sandro
#!/usr/bin/python

import gtk
import gobject

class Tree(object):
    def __init__(self):
        self.w = gtk.Window()
        self.t = gtk.TreeView()
        self.w.add(self.t)

        self.model = gtk.ListStore(gobject.TYPE_FLOAT)
        #self.model = gtk.ListStore(object)
        self.t.set_model(self.model)
        self.cell = gtk.CellRendererText()
        self.cell.set_property('editable', True)
        self.cell.set_property('editable-set', True)

        self.col = gtk.TreeViewColumn('float')
        self.col.pack_start(self.cell)
        #self.col.add_attribute(self.cell, 'text', 0 )
        self.col.set_cell_data_func(self.cell, self.cell_cb, )
        self.t.append_column(self.col)
        self.fill_model()
        self.w.show_all()

    def cell_cb(self, column, cell, model, iter, ):
        """function set by set_cell_data_func
        gets the attribute from the record and returns it
        """

        value = self.model.get_value(iter, 0) 
        cell.set_property('text', value)        
        
    def fill_model(self):
        for i in (1.2, 2.3, 4.32):
            self.model.append([i])

        print len(self.model)

import locale
locale.setlocale(locale.LC_NUMERIC, '')

t = Tree()


gtk.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