diff --git a/gramps/gen/constfunc.py b/gramps/gen/constfunc.py index 78895741c..8ac93dedf 100644 --- a/gramps/gen/constfunc.py +++ b/gramps/gen/constfunc.py @@ -64,6 +64,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 c3c040d1a..e37d133e3 100644 --- a/gramps/gui/glade.py +++ b/gramps/gui/glade.py @@ -47,7 +47,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 #------------------------------------------------------------------------ # @@ -122,7 +122,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