wxFont.SetDefaultEncoding: HyperLinkCtrl working, wxStaticText don't

Tigran Łaczinian seniortigr at gmail.com
Thu Apr 19 15:33:03 PDT 2007


Greetings.

I've developed recently an application using wxPython, now I'm trying
to add more languages to it and have some problem which I cannot solve
even after a week of googling and reading different manuals, so I've
decided to post it here.

Generally I'm trying now to run Russian language and cyryllic encoding. I have
wxFont.SetDefaultEncoding(wxFONTENCODING_CP1251)
line in OnInit method, before any frame is created and any font is used.

When application loads up, generally there is no text with cyrillic
encoding, only with my system one (cp1250) . But in one window, where
I have a couple of HyperLinkCtrl controls, the text on them is
displayed in correct (cyrillic) encoding. wxStaticTexts in that window
are displaying in wrong encoding. All controls in that window have the
same font (difference only that wxStaticText is bolded).
I've checked that text controls returns good encoding when trying
text.GetFont().GetEncoding() - but it didn't use it on the screen.

There is a part of code:
        sizer1 = wxBoxSizer(wxHORIZONTAL)
        text = wxStaticText(self, -1, LANG.GetString('ABOUT_VER'))

        text.SetFont(wxFont(11, wxNORMAL, wxNORMAL, wxBOLD))

        print wxFont.GetDefaultEncoding() # I'm checking is it worked
and it returns 32

        text.SetForegroundColour(COLOUR_FORHASSIST)

        print text.GetFont().GetEncoding() # This also returns 32
which is wxFONTENCODING_CP1251

        sizer1.Add(text, 0, wxALIGN_LEFT|wxTOP|wxLEFT|wxEXPAND, 20)

        text = wxStaticText(self, -1,
                            "(c) 2006-2007%sTigran Łaczinian" %
                            LANG.GetString('ABOUT_BY'))
        text.SetFont(wxFont(11, wxNORMAL, wxNORMAL, wxBOLD))
        text.SetForegroundColour(COLOUR_FORHASSIST)

        sizer1.Add(text, 0, wxALIGN_RIGHT|wxTOP|wxRIGHT|wxLEFT|wxEXPAND, 20)

        sizer.Add(sizer1, 1, wxALIGN_CENTER)

        sizer1 = wxBoxSizer(wxHORIZONTAL)

        hlink = hl.HyperLinkCtrl(self,
                              wxID_ANY, LANG.GetString('ABOUT_MAIL'),
                              URL="mailto:%s" % MAIL)

        hlink.SetFont(wxFont(11, wxNORMAL, wxNORMAL, wxNORMAL))
        hlink.SetForegroundColour(COLOUR_FORHASSIST)
        hlink.OpenInSameWindow(False)

        sizer1.Add(hlink, 0, wxALIGN_LEFT|wxTOP|wxLEFT|wxEXPAND, 20)

        hlink = hl.HyperLinkCtrl(self,
                              wxID_ANY, LANG.GetString('ABOUT_PAGE'),
                              URL=PAGEURL)

        hlink.SetFont(wxFont(11, wxNORMAL, wxNORMAL, wxNORMAL))
        hlink.SetForegroundColour(COLOUR_FORHASSIST)
        hlink.OpenInSameWindow(False)

        sizer1.Add(hlink, 0, wxALIGN_CENTER|wxTOP|wxLEFT|wxRIGHT|wxEXPAND, 20)

        hlink = hl.HyperLinkCtrl(self,
                              wxID_ANY, LANG.GetString('ABOUT_FORUM'),
                              URL=FORUMURL)

        hlink.SetFont(wxFont(11, wxNORMAL, wxNORMAL, wxNORMAL))
        hlink.SetForegroundColour(COLOUR_FORHASSIST)
        hlink.OpenInSameWindow(False)

        sizer1.Add(hlink, 0, wxALIGN_RIGHT|wxTOP|wxRIGHT|wxEXPAND|wxBOTTOM, 20)

        sizer.Add(sizer1, 1, wxALIGN_CENTER)

Other controls (column names in wxListView) are also displaying in
wrong encoding.

Is there something that I've missed which gives such effect? Please
give me some good advice.

I have writing it with Python 2.4.3 and wxPython 2.6.3 on Windows XP
Professional.

-- 
Tigran Łaczinian
seniortigr/at/gmail.com


More information about the wxpython-users mailing list