diff options
| author | Huang Peng <shawn.p.huang@gmail.com> | 2008-08-19 09:21:05 +0800 |
|---|---|---|
| committer | Huang Peng <shawn.p.huang@gmail.com> | 2008-08-19 09:21:05 +0800 |
| commit | 539913da27823ee2884b60db92ae87a94d654069 (patch) | |
| tree | fa5895a1db2eacf7f855c4e431f18506ad9c0f21 | |
| parent | ec51a56f8e2e788f303e687186ffe402729081d9 (diff) | |
| download | ibus-539913da27823ee2884b60db92ae87a94d654069.tar.gz ibus-539913da27823ee2884b60db92ae87a94d654069.tar.xz ibus-539913da27823ee2884b60db92ae87a94d654069.zip | |
Translate str to unicode.
| -rw-r--r-- | ibus/property.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/ibus/property.py b/ibus/property.py index 1f8e3f9..5a952e7 100644 --- a/ibus/property.py +++ b/ibus/property.py @@ -46,6 +46,12 @@ PROP_STATE_UNCHECKED = 0 PROP_STATE_CHECKED = 1 PROP_STATE_INCONSISTENT = 2 +def _to_unicode(text): + if isinstance(text, unicode): + return text + if isinstance(text, str): + return unicode(text, "utf8") + class Property(object): def __init__(self, name, type = PROP_TYPE_NORMAL, @@ -56,7 +62,7 @@ class Property(object): visible = True, state = PROP_STATE_UNCHECKED): super(Property, self).__init__() - self.__name = name + self.__name = _to_unicode(name) self.__type = type self.label = label self.icon = icon @@ -79,19 +85,19 @@ class Property(object): return self.__type def set_label(self, label): - self.__label = label + self.__label = _to_unicode(label) def get_label(self): return self.__label def set_icon(self, icon): - self.__icon = icon + self.__icon = _to_unicode(icon) def get_icon(self): return self.__icon def set_tooltip(self, tooltip): - self.__tooltip = tooltip + self.__tooltip = _to_unicode(tooltip) def get_tooltip(self): return self.__tooltip |
