[PyQt] Using Unicode

Gabriel Hahmann gabriel.hahmann at gmail.com
Wed Jun 17 08:13:21 BST 2009


Hi,

I'm new to the list and new to programming in python QT and I'm having
a little problem dealing with accent characters.

I have a little program that have the text sent to the user interface
using something like this:

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

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

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

self.set_status_text('Username', True)

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

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.

What I want to do is simply tranlate this program, I dont want it to
be internationalized, I mean, changing it in a way that it can be
tranlated again easily.

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.

If anyone can help me I will really appreciate, just to give me some
more things to try!!

Thanks in advance.

Gabriel.



More information about the PyQt mailing list