[pygtk] RE: Py2exe, TextView encoding problem ...

Greg McClure gmcclure at gmail.com
Thu Feb 24 08:45:24 WST 2005


Dear PyGTKers,

Got the bug.

I emailed my SoCal Piggies group and a member suggested that I ensure
that py2exe was including the encodings.utf_8 module due to py2exe's
mazy module finding mechanism.

I altered my setup.py to look like:

...
opts = {
    'py2exe': 'includes': 'atk,gobject,encodings.utf_8'
    ...
}
...

and voila! Everything worked fine.

All best,
Greg

*****

I have an app writing data from an XML file to a TextBuffer obtained
in the usual way:

tv = gtk.TextView()
buffer = tv.get_buffer()

self._buff_ref = buffer

and then ...

def write_buffer(self, buffer, text):
    buffer.set_text(text)
    tag = buffer.create_tag(None, size_points=20.0)
    start, end = buffer.get_bounds()
    buffer.apply_tag(tag, start, end)

and then later on there'll be something like

self.write_buffer(self._buff_ref, 'Happy happy joy joy')

My problem is that when the app runs as a Python application
everything works fine, and latin characters like 'í', 'ó' and 'ñ'
display as they should. This normally wouldn't be a problem except
that when I compile the app with py2exe and run the .exe file in
dist/, normal ascii text displays just fine but the latin characters
make the app choke that the character is outside the ascii range.

Yah!!! Help!!! If I do something like:

buffer.set(text.encode('utf-8'))

this doesn't help me out, the py2exe .exe file complains that it can't
find the encoder. I must be missing something straightforward. Any
help would be deeply appreciated.

All best,
Greg


More information about the pygtk mailing list