On Wed, 29 Jun 2011 02:52:08 AM Phil Thompson wrote: > On Tue, 28 Jun 2011 21:53:21 +1000, Algis Kabaila <[email protected]> > > wrote: > > Hi, > > > > Attempting to move to Python3 turned up a problem with resource > > compilation > > and/or installation into program. In my multi-partition box there are > > two > > > kubuntu 11.04 "natty" os's. Their names according to the desktop images > > are > > "Red Leaves" for Python3 > > "Winter Swans" for Python2 > > The same small script with tiny resource file runs ok on "Winter Swans", > > but > > fails to compile resources into the program on "Red Leaves". > > > > Here are the two compilation/running dialogs: > > > > On the Red Leave > > ================ > > pyhon 3.2 > > sip 4.12.3 > > qt 4.7.2 > > pyqt 4.8.4 > > > > > > menu.qrc > > -------- > > <!DOCTYPE RCC><RCC version="1.0"> > > <qresource> > > <file alias="hi.png">icons/address-book-new.png</file> > > <file alias="quit.png">icons/no.png</file> > > </qresource> > > </RCC> > > > > compiling > > --------- > > ak@supremo:/dat/work/py2/menubar$ pyrcc4 menu.qrc -o qrc_menu.py > > ak@supremo:/dat/work/py2/menubar$ python3 menu_r.py > > > > Traceback (most recent call last): > > File "menu_r.py", line 7, in <module> > > > > import qrc_menu > > > > File "/dat/work/py2/menubar/qrc_menu.py", line 269, in <module> > > > > qInitResources() > > > > File "/dat/work/py2/menubar/qrc_menu.py", line 264, in qInitResources > > > > QtCore.qRegisterResourceData(0x01, qt_resource_struct, > > qt_resource_name, > > > > qt_resource_data) > > TypeError: qRegisterResourceData(int, str, str, str): argument 2 has > > unexpected type 'str' > > ak@supremo: > > > > On the "Winter Swans" > > ===================== > > OS ubuntu 10.10 upgraded to 11.04 "natty" > > python 2.7.1+ > > pyqt 4.8.3 > > qt 4.7.2 > > > > ak@supremo:/dat/work/py2/menubar$ pyrcc4 menu.qrc -o qrc_menu.py > > ak@supremo:/dat/work/py2/menubar$ python2.7 menu_r.py > > QInotifyFileSystemWatcherEngine::addPaths: inotify_add_watch failed: No > > such > > file or directory > > QFileSystemWatcher: failed to add paths: /home/ak/.config/ibus/bus > > ak@supremo:/dat/work/py2/menubar$ > > > > The gui works ok. > > > > The script is listed below > > > > **************** > > *#!/usr/bin/python3 > > # menu_r.py - menu bar with resources. > > > > import sys > > from PyQt4 import QtGui > > > > import qrc_menu > > > > class MainWindow(QtGui.QMainWindow): > > > > # def __init__(self): > > def __init__(self, parent=None): > > super(MainWindow, self).__init__(parent) > > > > # QtGui.QMainWindow.__init__(self) > > > > self.resize(300,200) > > self.setWindowTitle('Menu and tool bar.') > > exit = QtGui.QAction(QtGui.QIcon(':/quit.png'),'Exit', self) > > exit.setShortcut('Ctrl+Q') > > exit.setStatusTip('Exit application') > > > > # > > self.connect(exit,QtCore.SIGNAL('triggered()'),QtCore.SLOT('close()')) > > > > exit.triggered.connect(self.close) > > toolBar = self.addToolBar('tools') > > toolBar.addAction(exit) > > self.centralwidget = QtGui.QWidget(self) > > self.gridLayout = QtGui.QGridLayout(self.centralwidget) > > self.plainTextEdit = QtGui.QPlainTextEdit(self.centralwidget) > > self.gridLayout.addWidget(self.plainTextEdit, 0, 0, 1, 1) > > MainWindow.setCentralWidget(self, self.centralwidget) > > self.statusBar() > > menubar = self.menuBar() > > file = menubar.addMenu('&File') > > file.addAction(exit) > > > > sayHiAction = QtGui.QAction(QtGui.QIcon(':/hi.png'), 'Greet > > them!', > > > > self) > > > > sayHiAction.setStatusTip('Say Hi') > > toolBar.addAction(sayHiAction) > > file.addAction(sayHiAction) > > sayHiAction.triggered.connect(self.sayHi) > > > > def sayHi(self): > > self.plainTextEdit.setPlainText('Hi Pete, hi world!') > > # setPlainText(text) clears the plainTextEdit window and puts > > fresh > > > > text. > > > > self.plainTextEdit.appendPlainText('Peace to all people of good > > > > will!') > > > > app = QtGui.QApplication(sys.argv) > > main = MainWindow() > > main.show() > > sys.exit(app.exec_()) > > ************* > > The PyQt compiled with python3.2 works fine, other than the problem with > > > > resources. My knee jerk reaction is that the error is likely to be in > > the > > > script pyrcc4, though that is only a guess. > > > > I would greatly appreciate any and all advice. There is no burning > > urgency > > for me, because it is quite possible to test the scripts with reading > > the > > > icon > > files directly, as was done in the original listing. However, this is > > *not > > really* satisfactory as moving the directory with all files to a > > different > > > location does cause problems "vanishing icons". > > Make sure you are passing the right flags to pyrcc4... > > http://www.riverbankcomputing.com/static/Docs/PyQt4/html/resources.html#pyr > cc4 > > Phil
That's kind of funny - I started a few weeks ago with pyrcc4 -py3 <etc..> a few weeks ago and all worked fine. Then I started doing more serious work and dropped the - py3... (well, my memory has become "short term" - the -py3 flag is even marked in my notes...). The "bug" appeared and left me wondering how did I manage to get the earlier examples working (no fool like an old fool). Sorry for the noise and a big *THANK YOU* for your tolerance and your magnificent work! OldAl. _______________________________________________ PyQt mailing list [email protected] http://www.riverbankcomputing.com/mailman/listinfo/pyqt
