[PyQt] non ascii names in QObject?

2011-11-24 Thread Victor Varvariuc
#!/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.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] non ascii names in QObject?

2011-11-24 Thread Hans-Peter Jansen
On Thursday 24 November 2011, 12:19:09 Victor Varvariuc wrote:
 #!/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.

In one word: don't.

Since PyQt has to respect the constraints of Qt (C++), what do you 
expect? After rewriting uic and qt designer, there's even more trouble 
ahead of your road (qt meta system, translation, ...) 

I have a hard time to find the upsides from this move in python3.
What would you think about some wonderful python open source 
application, that is written with all kind of _labels_ in hanzi, kanji 
or hanja? I guess, it would prevent you from modifying anything in that 
code. Similar, a lot of people in the world are lost with cyrillic 
labels. 

Imagine, Phil would write his code in some gaelic language? Even if  
(mostly) ascii based, only a small population would be able to 
understand the code. To get this straight: even written with proper 
english labels, comments and docuemtation, it's hard to grok 
completely. Try it.

Unicode labels are a silly form of obfuscation to me. 
If you like that, why don't you start hacking in APL, then?

Pete
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt