diff --git a/gramps/gen/constfunc.py b/gramps/gen/constfunc.py index 40764083d..28e50b703 100644 --- a/gramps/gen/constfunc.py +++ b/gramps/gen/constfunc.py @@ -66,6 +66,15 @@ cuni = conv_to_unicode_direct def conv_to_unicode(x, y='utf8'): return x if x is None or isinstance(x, UNITYPE) else cuni(x, y) +def uni_to_gui(x): + ''' + In Py2 we need to convert strings to utf8 before passing them to + Gtk functions. + ''' + if sys.version_info[0] < 3 and isinstance(x, UNITYPE): + return x.encode('utf8') + else: + return x # handle in database is bytes, while internally Gramps wants unicode for py3 if sys.version_info[0] < 3: diff --git a/gramps/gui/glade.py b/gramps/gui/glade.py index bcb1b2bb8..bc57f00fb 100644 --- a/gramps/gui/glade.py +++ b/gramps/gui/glade.py @@ -49,7 +49,7 @@ from gi.repository import Gtk # #------------------------------------------------------------------------ from gramps.gen.const import GLADE_DIR, GRAMPS_LOCALE as glocale -from gramps.gen.constfunc import STRTYPE +from gramps.gen.constfunc import STRTYPE, uni_to_gui #------------------------------------------------------------------------ # @@ -124,7 +124,7 @@ class Glade(Gtk.Builder): # try to build Gtk objects from glade file. Let exceptions happen - self.add_from_file(path) + self.add_from_file(uni_to_gui(path)) self.__dirname, self.__filename = os.path.split(path) # try to find the toplevel widget