[PyQt] Using Unicode

Gabriel Hahmann gabriel.hahmann at gmail.com
Wed Jun 17 09:31:46 BST 2009


Thank you very much Raoul, but as I don't have much experience, could
you be more specific, using an example based on my code?

Are you saying something like this:

QtGui.QPushButton(self.tr(u'&Next >'))

self.setWindowTitle(self.tr(u'Setup').arg(len(self.history)).arg(self.num_pages))

self.topTitle = QtGui.QLabel(self.tr(u'<center><b>Warning</center>')

self.set_status_text(u'Username', True)

label_text = u'Warning'
self.top_label = QtGui.QLabel(self.tr(label_text))

Is that what you mean? Putting an "u" before each string? I´m looking
some information about unicode and python and in a few pages I saw
that is necessary to do something to decode and show this on screen,
is that true?

[]'s
Gabriel.

On Wed, Jun 17, 2009 at 9:38 AM, Raoul
Snyman<raoul.snyman at saturnlaboratories.co.za> wrote:
> Hi Gabriel,
>
> On Wed, 17 Jun 2009 09:13:21 +0200, Gabriel Hahmann wrote:
>> QtGui.QPushButton(self.tr('&Next >'))
>>
>> In fact this is some excerpt of parts of the code. What I want to do
>> is translate every word of the text to Portuguese. I tried simply
>> translating but then it gives me an error of outside ASCII range.
>>
>> Then I added coding: utf-8 at the top of the file. Changed self.tr to
>> self.trUtf8 with no luck. I tried self.tr(unicode("Some text")) with
>> no luck too.
>>
>> The Portuguese characters have é, ç, ê, ô, etc. I tried with
>> self.trUtf8 and putting the code in hex like this self.trUtf8("\00C9")
>> without success. I've read a lot of pages telling how to print unicode
>> characters but I couldnt print a single character right now.
>
> Unfortunately I am English, so I haven't run into these problems myself,
> but a project I'm working on at the moment is having similar problems with
> one of our German testers. One thing I did notice in your code is that you
> are not sending Unicode strings through. Try using the u'Some Text' (note
> the "u") and see if that helps?
>
> Let us know if this has any effect.
>
> --
> Raoul Snyman, B.Tech IT (Software Engineering)
> Saturn Laboratories
> e: raoul.snyman at saturnlaboratories.co.za
> w: http://www.saturnlaboratories.co.za/
> b: http://blog.saturnlaboratories.co.za/
>   http://raoulsnyman.co.za/
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>



More information about the PyQt mailing list