Question

My setup is PyQT4.10 (QT4.8.5) with Python 2.7 on Windows 7. Using pyuic4 to convert .ui files to Python codes always generates codes that use QtCore.QString.fromUtf8 and QtGui.QApplication.translate for string translation. Since there are only English characters in my programs, such translation is unnecessary and removing them can make the generated Python codes having a consistent style with the existing codes. It seems pyuic4 does not come with a switch to turn it off. Is there a way to disable this translation? Thanks.

Was it helpful?

Solution

No, you cannot turn this off.

The pyuic tool generates boiler-plate code and it needs to maintain backwards compatibility. So there are several aspects of these modules that differ from how you might write the same code yourself. To give another obvious example: with pyuic4, signals are connected using the old-style syntax, rather than the much more readable new-style syntax.

But really, why should you care about this? Obviously, there is never a good reason to edit these files yourself, and it is easy enough to exclude them from version control. So apart from ensuring that they are re-generated whenever appropriate, you can more or less forget that they are there.

If you have not installed a translator, the various tr functions are all effectively NO-OPs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top