Type of GtkEntry text property
- From: Manuel Quiñones <manuq laptop org>
- To: python-hackers-list gnome org
- Subject: Type of GtkEntry text property
- Date: Mon, 18 Jun 2012 18:51:39 -0300
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
'coru\xc3\xb1a'
>>> type(entry.props.text)
str
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:
http://bugs.sugarlabs.org/attachment/ticket/2830/0001-Use-UNICODE-string-to-search-into-places-SL-2830.patch
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]