[wxPython-users] ANN: GUI2Exe for wxPython :-D

Andrea Gavana andrea.gavana at gmail.com
Thu Apr 5 01:58:57 PDT 2007


Hi Robin,

On 4/4/07, Robin Dunn wrote:
> Andrea Gavana wrote:
>
> >> And removed
> >> wx.SetDefaultPyEncoding("utf-8")
> >
> > No, don't do that. If you encode everything using UTF-8, I can enter a
> > project name like this:
> >
> > MyProject (some kind of french/german/russian/whatever non-ascii
> > non-cp1252 letter)
> >
> > And, while the database will recognize them (because you are encoding
> > them as UTF-8), the tree control on the left will not display the
> > project names correctly, as wxPython will use
> > wx.GetDefaultPyEncoding(), which returns the string encoding
> > for the system at the moment. That means, if you send me your
> > database, my tree control will probably display a bunch of squares
> > instead of the names you have used (if you used hebrew letters, for
> > example). I may be wrong here, so please everyone enlight me if I am
> > saying stupid things.
>
> Just for clarification, the wx.SetDefaultPyEncoding value only sets the
> codec to be used when wxPython needs to convert to/from unicode/ansi for
> wx methods and functions only.  This value usually defaults to
> locale.getpreferredencoding() so it matches what Python thinks is the
> default for your system as it is currently configured.  It doesn't have
> any effect on any other automatic conversions or coercions that Python
> will try to.

Ok, thank you for the explanation.

> For example, if you have a Unicode build of wxPython, and pass a string
> object to textctrl.SetValue, then it will use the
> wx.GetDefaultPyEncoding() encoding to convert it to a Unicode object to
> pass to the C++ SetValue.  The opposite is also true, if you have an
> ansi build of wxPython and pass a Unicode object then that encoding will
> be used to convert it to a string first.

Well, let's assume I have an unicode build of wxPython. Then Roee
sends me his database of GUI2Exe projects, and he has put in there
project names with hebrew letters (or cyrillic or whatever). My
database pre-processing will not blink, but on my machines
wx.GetDefaultPyEncoding() returns either 'cp1251' (here at work) or
'ascii' at home. Will it harm if I receive Roee's database?

> For other automatic ansi/unicode conversions that Python does then it
> uses the return value of sys.getdefaultencoding() for the encoding.
> Python also provides the sys.getfilesystemencoding() value which
> specifies what should be used for encoding unicode values into ansi
> strings to be used for path and file names on the current system.

sys.getdefaultencoding() seems not enough to work with bsddb, also
Roee reported the same problem. And I found exactly the same when
assigning project names with accented letters (french, german and
similar). I saved a project in the database with this strange name,
closed GUI2Exe, reopened it and the project name was completely
screwed up :-(

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77/




More information about the wxpython-users mailing list