[socal-piggies] Py2exe, PyGTK TextView encoding problem nightmare hassle annoyance ...

Daniel Arbuckle djarb at highenergymagic.org
Wed Feb 23 16:22:32 PST 2005


Just an off the cuff guess, but perhaps py2exe is not able to recognize
that lib/python2.x/encodings/utf_8.py* should be included in the
application? The codecs are imported through a rather roundabout
mechanism.

On Wed, Feb 23, 2005 at 04:05:13PM -0800, Greg McClure wrote:
> Hello my fellow Piggies!
> 
> I've copied the text of a message I posted to the PyGTK mailing list
> in hopes that someone in our group might have some experience with
> PyGTK and would have an inkling of what I'm doing incorrectly. I feel
> like I'm missing something plain because my problem seems as though it
> would be fairly common if what was trying to do was really tricky. It
> seems like a fairly straightforward, common task.
> 
> In short, I'm extracting some character data from an XML file, much of
> which is in Spanish or French or German, whatever, and writing the
> data to a TextBuffer obtained from a PyGTK TextView. The app works
> fine when run under the Python interpreter, but when I run the app
> through py2exe, well, the app starts up just fine and processes ascii
> text all right, but chokes on any latin characters, like '?', '?' or
> '?'.
> 
> Argh!
> 
> I've checked the PyGTK docs and, offhand, I don't seem to be missing
> any TextView or TextBuffer properties which would futz with the
> encoding. Also, GTK 2.0+ handles UTF-8 by default, right?
> 
> Any insights would be appreciated.
> 
> 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.
> 
> _______________________________________________
> socal-piggies mailing list
> socal-piggies at lists.idyll.org
> http://lists.idyll.org/listinfo/socal-piggies




More information about the socal-piggies mailing list