Hello, Ed, Hraban and Nick.
I've found a nice way to solve the "dabo demo problem" with my
"latin-1"="iso8859-1" character set, without changing a single line of the
dabo framework.
Simply create a file " sitecustomize.py" under Lib\site-packages in my
python directory:
# sitecustomize.py
# this file can be anywhere in your Python path,
# but it usually goes in ${pythondir}/lib/site-packages/
import sys
sys.setdefaultencoding('iso8859-1')
This method "set the current default string encoding used by the Unicode
implementation" (Python library reference).
Before I made this 'discovery', I've tested Nick's proposal :
cd, ch = evt.keyCode, unicode(evt.keyChar, dabo.getEncoding())
. . . and :
File "C:\Projects\dabo\demo\samples/dTextBox.py", line 55, in
onTextKeyChar
def onTextKeyChar(self, evt):
AttributeError: 'module' object has no attribute 'getEncoding'
It seems that my dabo has no getEncoding() method.
The solution Ed gave me : to put 'settings_override.py' file in demo
folder, with line : defaultEncoding = "latin-1" did not work (no error, but
no different results).
Ok, now I'm done with the demo. It goes OK.
So I begin exploring the Dabo AppWizard and I've generated the CRUD/File
Management form. When I go to see the grid of customers (the Browse tab):
lots of wrong characters in the name and address columns!
Then, I've entered a new record and -Eureka, it's ok! -The new record is
exactly as I've entered. So, the other records already entered in the online
database were input by other users with other encodings. PHEW! Big relief.
melkarth
-----Original Message-----
From: [email protected] [mailto:[email protected]] On
Behalf Of Nick Raptis
Sent: sábado, 21 de mayo de 2011 14:57
To: [email protected]
Subject: Re: [dabo-users] Reenv: Problem in Dabo demo
Just my 2 cents:
On 05/21/2011 10:02 AM, melkarth0 wrote:
> Finally, it seems that I'm bound to 'latin-1' encoding.
>
I'm starting to think that this is about wx putting a value to keyChar in
your systems default encoding instead of utf-8
> I changed line 56 in dTextBox.py, in onTextKeyChar() section in the demo:
>
> cd, ch = evt.keyCode, evt.keyChar
>
> for this one:
>
> cd, ch = evt.keyCode, unicode(evt.keyChar, 'latin-1')
>
> and now runs fine and logit() displays a beautiful a-acute.
>
> More, unicode(evt.keyChar, 'utf-8') doesn't work.
>
unicode(evt.keyChar, 'latin-1') actually sounds pretty sane.
You just need to dynamically get the default encoding via a property instead
of hardcoding it.
I think this is dabo.getEncoding(), so try
unicode(evt.keyChar, dabo.getEncoding())
Most of us don't see this error because our default encoding is utf-8
anyway.
> But, please, if anybody has a better approach, make me know it. I have
> a conceptual confusion with this encodings stuff. For example, if I
> put the line # -*- coding: latin-1 -*- on all the affected demo
> modules, will it works as is?
>
> Greetings
> Melkarth
>
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/[email protected]
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message:
http://leafe.com/archives/byMID/[email protected]