Hi. I am writing
an application in English (code
and GUI) that will have a multiline wx.TextCtrl into which the user can
type
Hebrew characters. Hebrew is a
right-to-left language. To further
complicate things, a vowel appears within the same text extent as its
associated consonant; for example, imagine an English “C” with a dot in
the
middle.
For the Hebrew characters to
appear correctly under Microsoft Windows XP, I need to take the
following steps
external to wxPython:
In
Windows’ Control Panel > Regional and Language Options >
Languages > Supplemental Language Support > [check box checked]
Install files for complex script and right-to-left languages (including
Thai).
On
the same Languages tab > Text services and input languages >
On
the same Settings tab > Preferences > Language Bar > [check
box checked] Show the Language bar on the desktop, [check box checked]
Show additional Language bar icons in the taskbar.
If I do not do steps 1 and 2
above, then the Hebrew characters do not appear properly; a vowel
appears next
to its associated consonant and not above|below|inside as it should. To switch
between typing Hebrew and English characters, I must either
select [EN]
or [HE] from the Windows’ taskbar, or press
[Left Alt] + [Shift] to change the input language.
Setting the wx.TextCtrl’s
font to a Hebrew font is not sufficient; the input language must also
be
changed as described in the previous paragraph.
Now, what I want to do is
try to avoid having my users perform steps 1, 2, and 3 above. Would making the application i18n compliant
remove the need to perform steps 1 and 2?
I can Bind the
wx.EVT_ENTER_WINDOW and wx.EVT_LEAVE_WINDOW event handlers to the
wx.TextCtrl
and execute a wx.TextCtrl.EmulateKeyPress( ) to send a [Left
Alt] + [Shift] to toggle between Hebrew
and English when entering and leaving the wx.TextCtrl, but this seems
to be a
bad hack.
Is there a better, pure
wxPython operating system independent solution?
A compromise would be to use
the Python Windows extension and call a Windows API function to swap
input
languages, but I do not read C++ and cannot decipher the Windows API
documentation at www.microsoft.com.
If the only solution is to
emulate the keypress [Left Alt] + [Shift] using
wx.TextCtrl.EmulateKeyPress( ),
how is it done? I cannot figure out how
to create the wxKeyEvent&event which is the
argument passed
to the function.
I apologize for this long
problem description but I wanted to be as clear as possible.
Hi. I am writing an application in English (code and GUI) that will have a multiline wx.TextCtrl into which the user can type Hebrew characters. Hebrew is a right-to-left language. To further complicate things, a vowel appears within the same text extent as its associated consonant; for example, imagine an English “C” with a dot in the middle.
For the Hebrew characters to appear correctly under Microsoft Windows XP, I need to take the following steps external to wxPython:
1. In Windows’ Control Panel > Regional and Language Options >
Languages > Supplemental Language Support > [check box checked]
Install files for complex script and right-to-left languages
(including Thai).
2. On the same Languages tab > Text services and input languages >
[Details button] > Installed Services > Settings > Add > Hebrew
3. On the same Settings tab > Preferences > Language Bar > [check box
checked] Show the Language bar on the desktop, [check box checked]
Show additional Language bar icons in the taskbar.
If I do not do steps 1 and 2 above, then the Hebrew characters do not appear properly; a vowel appears next to its associated consonant and not above|below|inside as it should. To switch between typing Hebrew and English characters, I must either select [EN] or [HE] from the Windows’ taskbar, or press [Left Alt] + [Shift] to change the input language.
Setting the wx.TextCtrl’s font to a Hebrew font is not sufficient; the input language must also be changed as described in the previous paragraph.
Now, what I want to do is try to avoid having my users perform steps 1, 2, and 3 above. Would making the application i18n compliant remove the need to perform steps 1 and 2?
No, i18n is mainly for allowing you to load different strings and etc. for your program based on the active language. You would still need to set up the system to support each of the languages you want to use in your program.
I can Bind the wx.EVT_ENTER_WINDOW and wx.EVT_LEAVE_WINDOW event handlers to the wx.TextCtrl and execute a wx.TextCtrl.EmulateKeyPress( ) to send a [Left Alt] + [Shift] to toggle between Hebrew and English when entering and leaving the wx.TextCtrl, but this seems to be a bad hack.
It's doubtful that it would work anyway. The EmulateKeypress will send the messages to the control, but I doubt that it is the text ctrl that is handling the language switch. I expect that it is a Windows hot-key and that the change is being done at a system level, not an application or control level.
Is there a better, pure wxPython operating system independent solution?
The only way I can think of is to create a custom widget for displaying and editing the Hebrew text. As far as I know the native widgets are designed to work with the system language/locale settings and can't be made to operate independently of that. (If there is a way it's not exposed in wxWidgets, and it's not in any of the MS docs I just did a quickie search through...) Since you are trying to use one language for the app and another language for this one control it doesn't really fit the model that it appears that the system provides.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
----- Original Message -----
From: Robin Dunn <robin@alldunn.com>
Date: Thursday, December 29, 2005 4:27 am
Subject: Re: [wxPython-users] How to automatically change the input language (character set) for a wxTextCtrl
Ira Kaplan wrote:
> Hi. I am writing an application in English (code and GUI) that
will
> have a multiline wx.TextCtrl into which the user can type Hebrew
> characters. Hebrew is a right-to-left language. To further
complicate
> things, a vowel appears within the same text extent as its
associated
> consonant; for example, imagine an English “C” with a dot in the
middle.>
> For the Hebrew characters to appear correctly under Microsoft
Windows
> XP, I need to take the following steps external to wxPython:
>
>
> 1. In Windows’ Control Panel > Regional and Language Options >
> Languages > Supplemental Language Support > [check box
checked]> Install files for complex script and right-to-left
> (including Thai).
>
> 2. On the same Languages tab > Text services and input
languages >
> [Details button] > Installed Services > Settings > Add >
>
>
>
> 3. On the same Settings tab > Preferences > Language Bar >
[check box
> checked] Show the Language bar on the desktop, [check box
checked]> Show additional Language bar icons in the taskbar.
>
>
> If I do not do steps 1 and 2 above, then the Hebrew characters
do not
> appear properly; a vowel appears next to its associated
consonant and
> not above|below|inside as it should. To switch between typing
Hebrew
> and English characters, I must either select [EN] or [HE] from
the
> Windows’ taskbar, or press [Left Alt] + [Shift] to change the
input
> language.
>
> Setting the wx.TextCtrl’s font to a Hebrew font is not
sufficient; the
> input language must also be changed as described in the previous
paragraph.>
> Now, what I want to do is try to avoid having my users perform
steps 1,
> 2, and 3 above. Would making the application i18n compliant
remove the
> need to perform steps 1 and 2?
No, i18n is mainly for allowing you to load different strings and
etc.
for your program based on the active language. You would still
need to
set up the system to support each of the languages you want to use
in
your program.
>
> I can Bind the wx.EVT_ENTER_WINDOW and wx.EVT_LEAVE_WINDOW event
> handlers to the wx.TextCtrl and execute a
wx.TextCtrl.EmulateKeyPress( )
> to send a [Left Alt] + [Shift] to toggle between Hebrew and
English
> when entering and leaving the wx.TextCtrl, but this seems to be
a bad hack.
It's doubtful that it would work anyway. The EmulateKeypress will
send
the messages to the control, but I doubt that it is the text ctrl
that
is handling the language switch. I expect that it is a Windows
hot-key
and that the change is being done at a system level, not an
application
or control level.
>
> Is there a better, pure wxPython operating system independent
solution?
The only way I can think of is to create a custom widget for
displaying
and editing the Hebrew text. As far as I know the native widgets
are
designed to work with the system language/locale settings and
can't be
made to operate independently of that. (If there is a way it's
not
exposed in wxWidgets, and it's not in any of the MS docs I just
did a
quickie search through...) Since you are trying to use one
language for
the app and another language for this one control it doesn't
really fit
the model that it appears that the system provides.
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
-------------------------------------------------------------------
--
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-
help@lists.wxwidgets.org