Hi, all<br><br>In PyQt Designer 4.5.2 I set the property 'text' of a
QPushButton to some Chinese characters, and when I run pyuic4 to
generate the coresponding .py file, it reports error, here is traceback:<br><br>
File "E:\Python26\lib\site-<div id=":tx" class="ii gt">packages\PyQt4\uic\port_v2\invoke.py", line 12, in invoke<br> exit_status = driver.invoke()<br> File "E:\Python26\lib\site-packages\PyQt4\uic\driver.py", line 37, in invoke<br>
self._generate()<br> File "E:\Python26\lib\site-packages\PyQt4\uic\driver.py", line 63, in _generate<br> self._opts.pyqt3_wrapper)<br> File "E:\Python26\lib\site-packages\PyQt4\uic\__init__.py", line 65, in compileUi<br>
winfo = compiler.UICompiler().compileUi(uifile, pyfile)<br> File "E:\Python26\lib\site-packages\PyQt4\uic\Compiler\compiler.py", line 66, in compileUi<br> w = self.parse(input_stream)<br> File "E:\Python26\lib\site-packages\PyQt4\uic\uiparser.py", line 768, in parse<br>
actor(elem)<br> File "E:\Python26\lib\site-packages\PyQt4\uic\uiparser.py", line 616, in createUserInterface<br> self.traverseWidgetTree(elem)<br> File "E:\Python26\lib\site-packages\PyQt4\uic\uiparser.py", line 594, in traverseWidgetTree<br>
handler(self, child)<br> File "E:\Python26\lib\site-packages\PyQt4\uic\uiparser.py", line 168, in createWidget<br> self.traverseWidgetTree(elem)<br> File "E:\Python26\lib\site-packages\PyQt4\uic\uiparser.py", line 594, in traverseWidgetTree<br>
handler(self, child)<br> File "E:\Python26\lib\site-packages\PyQt4\uic\uiparser.py", line 168, in createWidget<br> self.traverseWidgetTree(elem)<br> File "E:\Python26\lib\site-packages\PyQt4\uic\uiparser.py", line 594, in traverseWidgetTree<br>
handler(self, child)<br> File "E:\Python26\lib\site-packages\PyQt4\uic\uiparser.py", line 162, in createWidget<br> self.stack.push(self.setupObject(widgetClass(elem), parent, elem))<br> File "E:\Python26\lib\site-packages\PyQt4\uic\uiparser.py", line 135, in setupObject<br>
self.wprops.setProperties(obj, branch)<br> File "E:\Python26\lib\site-packages\PyQt4\uic\properties.py", line 271, in setProperties<br> getattr(widget, "set%s%s" % (ascii_upper(propname[0]), propname[1:]))(self.convert(prop, widget))<br>
File "E:\Python26\lib\site-packages\PyQt4\uic\properties.py", line 231, in convert<br> return func(prop[0], **args)<br> File "E:\Python26\lib\site-packages\PyQt4\uic\properties.py", line 214, in _font<br>
getattr(newfont, "set%s" % (attr,))(converter(v))<br>UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)<br><br>It seems pyuic4 cannot handle Chinese characters correctly. Is there anyway to deal with unicode? Many thanks.</div>