Reputation: 3
The python code: menu_item = gtk.MenuItem("après")
gives a warning message: Gtk warning Invalid input string
and the menu item is not shown. What should I add / change to have the menu item displayed?
Upvotes: 0
Views: 601
Reputation: 154886
Your editor is most likely saving the source file in another encoding, such as Latin-1 or Windows-1252, where GTK expects UTF-8. Try replacing "après"
with u"apr\u00e8s".encode("utf-8")
. If that makes it work, the problem lies there.
To correctly fix the problem, you need to:
# -*- coding: utf-8 -*-
u"après"
instead of "après"
. Where unicode strings are not accepted, use u"après".encode("utf-8")
. PyGTK generally accepts Unicode strings, so explicit encoding to UTF-8 should not be necessary.Upvotes: 1