Where to put wx.Font.SetDefaultEncoding(wx.FONTENCODING_...)

Hi Friends,

I need a setting so that WinCyrillic (cp1251) texts are displayed
correctly in wxPython's controls.

I was told by a fellow developer named Niki Spahiev that I need the
following "global setting"
(I am not quite sure if "global setting" is the right tern for this in
wxPython)

wx.Font.SetDefaultEncoding(wx.FONTENCODING_CP1251)

in wxPython 2.6.0-ansi-win32 with Python 2.4.1 on OS Win98 SE.

I use wxPython with Boa Constructor and I tried the setting almost
everywhere in the source files (application and frame) but either I got
error of the type "wx.App should be created before using" or the code
did not produced the result desired - I see cyrillic strings in the
form of backslashed hex values.

Actually I found a similar post at

http://lists.wxwidgets.org/archive/wxPython-users/msg08726.html

but the exact location of the setting was not speciafied. So I hope you
can help me.

Best regards,
degoor

degoor_widgets@dir.bg wrote:

Hi Friends,

I need a setting so that WinCyrillic (cp1251) texts are displayed
correctly in wxPython's controls.

I was told by a fellow developer named Niki Spahiev that I need the
following "global setting"
(I am not quite sure if "global setting" is the right tern for this in
wxPython)

wx.Font.SetDefaultEncoding(wx.FONTENCODING_CP1251)

in wxPython 2.6.0-ansi-win32 with Python 2.4.1 on OS Win98 SE.

I use wxPython with Boa Constructor and I tried the setting almost
everywhere in the source files (application and frame) but either I got
error of the type "wx.App should be created before using" or the code
did not produced the result desired

Anywhere after the app object has been created and before where the fonts are created would be fine. You may also want to consider using wx.Locale to set other parts of the system to be aware that the app is running with different settings. See also http://wiki.wxpython.org/index.cgi/RecipesI18n

- I see cyrillic strings in the
form of backslashed hex values.

See my other post. I really think that this is another problem of some sort. There is nothing in wxWidgets C++ code that will convert the string to Python's backslash representation, so I think that if that is what is showing in a GUI widget then you must be doing some conversion somehere that is transforming the string before it gets to the C++ code. Please try to reproduce it in small sample app that others can use to help you diagnose the problem.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Hi Friends,

I need a setting so that WinCyrillic (cp1251) texts are displayed
correctly in wxPython's controls.

I was told by a fellow developer named Niki Spahiev that I need the
following "global setting"
(I am not quite sure if "global setting" is the right tern for this in
wxPython)

wx.Font.SetDefaultEncoding(wx.FONTENCODING_CP1251)

in wxPython 2.6.0-ansi-win32 with Python 2.4.1 on OS Win98 SE.

I use wxPython with Boa Constructor and I tried the setting almost
everywhere in the source files (application and frame) but either I got
error of the type "wx.App should be created before using" or the code
did not produced the result desired - I see cyrillic strings in the
form of backslashed hex values.

Actually I found a similar post at

http://lists.wxwidgets.org/archive/wxPython-users/msg08726.html

but the exact location of the setting was not speciafied. So I hope you
can help me.

Best regards,
degoor

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

# sitecustomize.py
# this file can be anywhere in your Python path,
# but it usually goes in ${pythondir}/lib/site-packages/
import sys, codecs
sys.setdefaultencoding('cp1251')

# It works for me here in Russia :wink: (win2000 + wxPython Ansi
# 2.6.something..)
# And of course you need to have cyrillic fonts installed.
# Try also:

···

#
# import locale
# locale.setlocale(locale.LC_ALL,'Russian_Russia.1251')
# on top of your script.

--
Igor.
                         mailto:igor@tyumbit.ru

Hi,

AFAIK sitecustomize.py approach will not works if application py2exe-ed.

    Vladimir Ignatov

···

# sitecustomize.py
# this file can be anywhere in your Python path,
# but it usually goes in ${pythondir}/lib/site-packages/
import sys, codecs
sys.setdefaultencoding('cp1251')

AFAIK sitecustomize.py approach will not works if application py2exe-ed.
    Vladimir Ignatov

I have py2exe'd application and i don't see this problem.

···

--
Igor
                         mailto:igor@tyumbit.ru