ilstam
ilstam

Reputation: 1594

pass no-ascii characters to the tr() internationalization method of PyQt4 with python3

Python3, PyQt4 and internationalization.

I want to pass some string containing non-ASCII characters to the tr() method of PyQt and I get the following error:

>>> from PyQt4.QtGui import QDialog
>>> from PyQt4.QtCore import QObject
>>> QDialog.tr(QObject(), 'abc')
'abc'
>>> QDialog.tr(QObject(), 'abcγδε')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: function takes exactly 5 arguments (1 given)
>>> 

How can I fix this?

Upvotes: 1

Views: 191

Answers (1)

Ramchandra Apte
Ramchandra Apte

Reputation: 4079

You need to use trUtf8(). tr() is for ASCII strings. (its signature is const char * sourceText, ...)

QDialog.trUtf8(QObject(), 'abcγδε')

Upvotes: 1

Related Questions