Type of GtkEntry text property

Hi, I was expecting that GtkEntry text property can handle Unicode
automatically, and return Unicode too, storing UTF-8 encoded gchar* in
the middle.  But seems to not be the case:

>>> from gi.repository import Gtk
>>> entry = Gtk.Entry()
>>> entry.props.text = u'coruña'
>>> entry.props.text

>>> type(entry.props.text)

Same happens using set_text() and get_text() methods instead of
changing the property.

>From IntrospectionPorting wiki page [1] this is one of the features of
Overrides "Another important case is automatic data type conversion,
most prominently to allow passing unicode objects to methods which
expect an UTF-8 encoded gchar*. This also actually helps to prevent
workarounds in application code and maintain a clean API".

[1] https://live.gnome.org/PyGObject/IntrospectionPorting

This unexpected behaviour was spotted in Sugar learning platform, and
the proposed workaround we have is decode the string in UTF-8:


But we are not going to push the workaround if this is an upstream bug
in pygobject.  Is this the case?

Thanks in advance,

.. manuq ..

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]