[PyQt] non ascii names in QObject?

Victor Varvariuc blind.vic at gmail.com
Thu Nov 24 11:19:09 GMT 2011


#!/usr/bin/env python3

from PyQt4 import QtGui, QtCore, uic

class Form(QtGui.QDialog):

    def __init__(self, parentWidget):
        super().__init__(parentWidget)
        self.setupUi()

    def setupUi(self):
        uic.loadUi('test.ui', self)

    def тест(self):
        '''This method has non ASCII name causing this error:
Traceback (most recent call last):
  File "test.py", line 20, in <module>
    form = Form(None)
  File "test.py", line 9, in __init__
    self.setupUi()
  File "test.py", line 12, in setupUi
    uic.loadUi('test.ui', self)
  File "/usr/lib/python3/dist-packages/PyQt4/uic/__init__.py", line
221, in loadUi
    return DynamicUILoader().loadUi(uifile, baseinstance)
  File "/usr/lib/python3/dist-packages/PyQt4/uic/Loader/loader.py",
line 71, in loadUi
    return self.parse(filename, basedir)
  File "/usr/lib/python3/dist-packages/PyQt4/uic/uiparser.py", line
925, in parse
    elem = document.find(tagname)
  File "/usr/lib/python3.2/xml/etree/ElementTree.py", line 726, in find
    return self._root.find(path, namespaces)
  File "/usr/lib/python3.2/xml/etree/ElementTree.py", line 363, in find
    return ElementPath.find(self, path, namespaces)
  File "/usr/lib/python3.2/xml/etree/ElementPath.py", line 285, in find
    return next(iterfind(elem, path, namespaces))
  File "/usr/lib/python3.2/xml/etree/ElementPath.py", line 249, in iterfind
    if path[-1:] == "/":
UnicodeEncodeError: 'ascii' codec can't encode characters in position
0-3: ordinal not in range(128)
        '''

if __name__ == '__main__':
    app = QtGui.QApplication([])
    form = Form(None)
    form.show()
    app.exec()


Python3 supports unicode names - which are working. Does Qt support
unicode names or it's a PyQt bug (see the example above)? Qt Designer
also doesn't allow me to enter non-ascii names for objects.


More information about the PyQt mailing list