Re: [PyQt] including Unicode in QListWidget

2012-06-18 Thread David Beck
 
 Message: 1
 Date: Mon, 18 Jun 2012 05:03:28 +0200
 From: Knacktus knack...@googlemail.com
 To: pyqt@riverbankcomputing.com
 Subject: Re: [PyQt] including Unicode in QListWidget
 Message-ID: 4fde9a80.50...@googlemail.com
 Content-Type: text/plain; charset=UTF-8; format=flowed
 
 Am 17.06.2012 22:55, schrieb David Beck:
 Message: 2
 Date: Sun, 17 Jun 2012 18:42:54 +0200
 From: Knacktus knack...@googlemail.com mailto:knack...@googlemail.com
 To: pyqt@riverbankcomputing.com mailto:pyqt@riverbankcomputing.com
 Subject: Re: [PyQt] including Unicode in QListWidget
 Message-ID: 4fde090e.1070...@googlemail.com
 mailto:4fde090e.1070...@googlemail.com
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 
 Am 17.06.2012 18:29, schrieb David Beck:
 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 calledOrth 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.
 
 Are you 100 % sure that unicode is handled properly while reading the
 xml? I never had problems with unicode and PyQt but I strictly using
 unicode strings only in my apps.
 
 This for example works for me (Python 2.7):
 
 # -*- coding: utf-8 -*-
 
 if __name__ == __main__:
 
 import sys
 from PyQt4.QtGui import *
 app = QApplication(sys.argv)
 list_widget = QListWidget()
 list_widget.addItem(u??^? l? l?)
 list_widget.show()
 app.exec_()
 
 
 Yes, it seems to be independent of the XML. For instance, I get the same
 thing when I run the little app below (the GUI is generated by pyuic4):
 
import sys
from PyQt4 import QtCore, QtGui
 
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
_fromUtf8 = lambda s: s
 
class Ui_UTFWidget(object):
def setupUi(self, UTFWidget):
UTFWidget.setObjectName(_fromUtf8(UTFWidget))
UTFWidget.resize(400, 300)
self.centralWidget = QtGui.QWidget(UTFWidget)
self.centralWidget.setObjectName(_fromUtf8(centralWidget))
self.listWidget = QtGui.QListWidget(self.centralWidget)
self.listWidget.setGeometry(QtCore.QRect(17, 9, 362, 241))
self.listWidget.setObjectName(_fromUtf8(listWidget))
UTFWidget.setCentralWidget(self.centralWidget)
self.menuBar = QtGui.QMenuBar(UTFWidget)
self.menuBar.setGeometry(QtCore.QRect(0, 0, 400, 22))
self.menuBar.setObjectName(_fromUtf8(menuBar))
self.menuUTF_test = QtGui.QMenu(self.menuBar)
self.menuUTF_test.setObjectName(_fromUtf8(menuUTF_test))
UTFWidget.setMenuBar(self.menuBar)
self.mainToolBar = QtGui.QToolBar(UTFWidget)
self.mainToolBar.setObjectName(_fromUtf8(mainToolBar))
UTFWidget.addToolBar(QtCore.Qt.TopToolBarArea, self.mainToolBar)
self.statusBar = QtGui.QStatusBar(UTFWidget)
self.statusBar.setObjectName(_fromUtf8(statusBar))
UTFWidget.setStatusBar(self.statusBar)
self.menuBar.addAction(self.menuUTF_test.menuAction())
 
self.retranslateUi(UTFWidget)
QtCore.QMetaObject.connectSlotsByName(UTFWidget)
 
def retranslateUi(self, UTFWidget):
UTFWidget.setWindowTitle(QtGui.QApplication.translate(UTFWidget,
UTFWidget, None, QtGui.QApplication.UnicodeUTF8))
self.menuUTF_test.setTitle(QtGui.QApplication.translate(UTFWidget,
UTF test, None, QtGui.QApplication.UnicodeUTF8))
 
class MyForm(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_UTFWidget()
self.ui.setupUi(self)
 
self.ui.listWidget.addItem(abcde)

Re: [PyQt] Qt5 roadmap?

2012-06-18 Thread Detlev Offenbach


On Sunday 17 June 2012, 20:11:34 Phil Thompson wrote:
 On Sun, 17 Jun 2012 19:38:13 +0200, Detlev Offenbach
 
 det...@die-offenbachs.de wrote:
  On Sunday 17 June 2012, 18:24:55 Phil Thompson wrote:
  On Sat, 16 Jun 2012 07:27:11 -0700, David Cortesi
 
 davecort...@gmail.com
 
  wrote:
   Folks,
   
   Per the Qt Project roadmap (http://qt-project.org/wiki/Qt_5.0) Qt
   5
 
 is
 
   supposed to be in beta now (the alpha is available at
   http://qt-project.org/prereleases), with final release by the end
   of
   June.
  
  I wouldn't put too much faith in those dates.
  
   I look in vain for a pyqt roadmap at riverbank.co.uk, although I
   do
 
 see
 
   roadmaps for sip and dip. So, what's the anticipation for PyQt5
   release?
   Any news?
  
  Qt5 support will be in two stages.
  
  Current PyQt4 snapshots build against the alpha release of Qt5 (QtCore
  and
  QtGui modules only at the moment). This will allow you to run your
  current
  PyQt4 code with Qt5. You will get any speed improvements, bug fixes
  etc
  in
  Qt5 but not any of the new functionality.
  
  There will be a PyQt5 that will support the new functionality of Qt5,
 
 and
 
  reflect its different structure (eg. QWidget will be in
  PyQt5.QtWidgets
  rather than PyQt4.QtGui). Backwards compatibility with PyQt4 will not
 
 be
 
  maintained.
  
  Is it planned to include a tool converting existing code from PyQt4 to
  PyQt5
  (something like 2to3 for Python)?
 
 No. It might be just a case of changing import statements.
 

If it is that simple I could do it myself.

Regards,
Detlev
-- 
Detlev Offenbach
det...@die-offenbachs.de___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt