[PyQt] including Unicode in QListWidget

David Beck dbeck at ualberta.ca
Tue Jun 19 17:32:07 BST 2012


Hi, Phil

Thanks for your suggestion. I tried the workaround at the bottom, but it didn't seem to have any effect. However, my installation seems not to match the path you gave (I don't seem to have a /path/to/qt/ directory at all that I can find). I installed PyQt from PyQt-mac-gpl-snapshot-4.9.2-d49ae8bd9152.tar. It created a directory right next to itself called "PyQt" and the mkspecs folder is inside that. I went there, entered the ln command, ran python3.3 configure.py ..., make and make install, but I'm still having the same issue when I run the GUI.

If tonight's snapshot might be a fix, I'll try to install that—would that just be a matter of replacing the existing PyQt folder and going through the configure > make > make install routine? (Sorry for all the dumb questions—I'm willing to admit I'm way in over my head here.)

David

On 2012-06-19, at 8:42 AM, Phil Thompson wrote:

> On Sun, 17 Jun 2012 10:29:58 -0600, David Beck <dbeck at ualberta.ca> wrote:
>> I am trying to build a GUI for navigating through a large XML database
> on
>> a Mac running OS 10.7, Python 3.3, PyQt 4. I want to get a list of the
> text
>> in all of the nodes called <Orth> and put them into a QListWidget called
>> "hLexNav". To do this, I wrote the following bit of code (this isn't the
>> whole thing, just the parts that are supposed to add items to the
> listbox):
>> 
>> 
>> import sys
>> from PyQt4 import QtCore, QtGui
>> from xml.dom import minidom
>> import xml.etree.ElementTree as etree
>> from fieldbookGui import Ui_Fieldbook
>> import images
>> import btnCmds
>> 
>> class MyForm(QtGui.QMainWindow):
>>  def __init__(self, parent=None):
>>    QtGui.QWidget.__init__(self, parent)
>>    self.ui = Ui_Fieldbook()
>>    self.ui.setupUi(self)
>> 
>> 
>>    xmltree = etree.parse('BabyDb.xml')
>>    root = xmltree.getroot()
>>    for child in root:
>>      self.ui.hLexNav.addItem(child.findtext('Orth'))
>> 
>> The first 25 items that are returned by child.findtext('Orth') are:
>> 
>> ['a:', 'a:cháj', 'a:chulá:', "a:hé:xtu'", 'a:ho:tán', 'a:kús',
>> "a:li:ma'htín", 'a:li:stá:n', 'a:má', "a:ma'ha:'pi'tzí'n",
> 'a:mixtzayán',
>> 'a:nanú:', 'a:tú:n', 'a:tzá:', "a:tzemá'j", 'a:xí:lh', 'a:xtúm',
> 'a:xú:x',
>> "a:'hála'", "a:'j", "a:'jmá", "a:'jnanú:", "a:'jtzá:", "a:'jtzananú:",
>> "a:'kní:"]
>> 
>> In the QListWidget created by this code, I see only items corresponding
> to
>> those elements that do not contain accented vowels (here, those that
> don't
>> contain "á", "ú", etc.); items that correpsond to strings with accented
>> vowels are left empty. Further experimentation with addItem( ),
> addItems(),
>> and insertItem( ) show that any string that contains an non-ASCII
> character
>> results in an empty Item being inserted into the QListWidget.
>> 
>> Any ideas about what is going on would be appreciated.
> 
> It's a compiler bug, see...
> 
> http://bugs.python.org/issue13241
> 
> Tonight's snapshot will disable the PEP 393 support if LLVM is being used.
> Another workaround is to enable Qt4's clang support...
> 
>    cd /path/to/qt/mkspecs
>    ln -s unsupported/macx-clang macx-clang
> 
> Phil
> 



More information about the PyQt mailing list