[PyQt] Loose com pointer when open a qt window
Hi all, I need some help or idea to a com problem.. I got this class: class foo(object): def setComObject(comObject): self.comO=comObject #This is a com object from a cad application def showForm(self) # use the self.comO to read some information from the cad application # Show the pyqt form as child of cad application # do somthing with the form # do somthing with the self.comO- Here if pass some time I'm not able to call any method to the com object a=foo() o=get istance of a cad application via com a.setComObject(o) a.showForm() # here if pass some time I'm not able to call any method to the com object but I I' re call the a.setComObject(o) #Faster and I take less the 30 seconds on the form object it works well It seems a problem of the garbage collector .. but I'm not sure how to debug it .. any help is really appreciated.. it's the last dangerous bug in our application ... Regards, Matteo ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Menu icons missing in Xfce
Hi, I have a Python 3/PyQt 4 application that has standard menus and toolbars and works fine under GNOME 2 on Debian 6. However, on Xubuntu (Xfce 4.8) the icons only show up in the toolbars not in the menus. Yet other applications (e.g., firefox, Archive Manager) have icons in their menus. Does anyone know the fix for this? Thanks! -- Mark Summerfield, Qtrac Ltd, www.qtrac.eu C++, Python, Qt, PyQt - training and consultancy Advanced Qt Programming - ISBN 0321635906 http://www.qtrac.eu/aqpbook.html ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] setCornerWidget for QMenuBar build Snapshots
On 06/12/2011 09:32 م, Phil Thompson wrote: Snapshots are only provided as source packages I tried to build the snapshots as following but I failed... could you please help me in building process? Build steps: Downloaded sip-4.13.1-snapshot-82af71f0adcb Configured SIP then built it Downloaded PyQt-win-gpl-snapshot-4.9-aea28dc027e5 Configured PyQt Downloaded NSIS Run nsi Here's builing logs: --- SIP --- Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation. All rights reserved. C:\Users\mbnoimi\Desktop\sip-4.13.1-snapshot-82af71f0adcbpath PATH=C:\Python27\Lib\site-packages\PyQt4;C:\Python27\Lib\site-packages\;C:\QtSDK \mingw\bin;C:\Python27\Scripts;C:\Python27;C:\Program Files\NVIDIA Corporation\P hysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\S ystem32\WindowsPowerShell\v1.0\;C:\Program Files\doxygen\bin;C:\Program Files\Wi nMerge;C:\Program Files\Bazaar;C:\Program Files\Microsoft SQL Server\100\Tools\B inn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\ C:\Users\mbnoimi\Desktop\sip-4.13.1-snapshot-82af71f0adcbpython configure.py This is SIP 4.13.1-snapshot-82af71f0adcb for Python 2.7.2 on win32. The SIP code generator will be installed in C:\Python27. The sip module will be installed in C:\Python27\Lib\site-packages. The sip.h header file will be installed in C:\Python27\include. The default directory to install .sip files in is C:\Python27\sip. The platform/compiler configuration is win32-msvc2008. Creating siplib\sip.h... Creating siplib\siplib.c... Creating siplib\siplib.sbf... Creating sipconfig.py... Creating top level Makefile... Creating sip code generator Makefile... Creating sip module Makefile... C:\Users\mbnoimi\Desktop\sip-4.13.1-snapshot-82af71f0adcbpython configure.py -- platform win32-g++ This is SIP 4.13.1-snapshot-82af71f0adcb for Python 2.7.2 on win32. The SIP code generator will be installed in C:\Python27. The sip module will be installed in C:\Python27\Lib\site-packages. The sip.h header file will be installed in C:\Python27\include. The default directory to install .sip files in is C:\Python27\sip. The platform/compiler configuration is win32-g++. Creating siplib\sip.h... Creating siplib\siplib.c... Creating siplib\siplib.sbf... Creating sipconfig.py... Creating top level Makefile... Creating sip code generator Makefile... Creating sip module Makefile... C:\Users\mbnoimi\Desktop\sip-4.13.1-snapshot-82af71f0adcbminggw32-make 'minggw32-make' is not recognized as an internal or external command, operable program or batch file. C:\Users\mbnoimi\Desktop\sip-4.13.1-snapshot-82af71f0adcbmingw32-make mingw32-make[1]: Entering directory `C:/Users/mbnoimi/Desktop/sip-4.13.1-snapsho t-82af71f0adcb/sipgen' makefile:29: warning: overriding commands for target `.c.o' makefile:26: warning: ignoring old commands for target `.c.o' gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -o main.o main.c gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -o transform.o trans form.c gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -o gencode.o gencode .c gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -o extracts.o extrac ts.c gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -o export.o export.c gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -o heap.o heap.c gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -o parser.o parser.c gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -o lexer.o lexer.c g++ -mthreads -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runt ime-pseudo-reloc -Wl,-subsystem,console -Wl,-s -o sip.exe main.o transform.o gen code.o extracts.o export.o heap.o parser.o lexer.o mingw32-make[1]: Leaving directory `C:/Users/mbnoimi/Desktop/sip-4.13.1-snapshot -82af71f0adcb/sipgen' mingw32-make[1]: Entering directory `C:/Users/mbnoimi/Desktop/sip-4.13.1-snapsho t-82af71f0adcb/siplib' makefile:29: warning: overriding commands for target `.c.o' makefile:26: warning: ignoring old commands for target `.c.o' gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -IC:\Python27\includ e -o siplib.o siplib.c gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -IC:\Python27\includ e -o apiversions.o apiversions.c gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -IC:\Python27\includ e -o descriptors.o descriptors.c gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -IC:\Python27\includ e -o qtlib.o qtlib.c gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -IC:\Python27\includ e -o threads.o threads.c gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -IC:\Python27\includ e -o objmap.o objmap.c gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -IC:\Python27\includ e -o voidptr.o voidptr.c g++ -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -IC:\Python27\includ e -o bool.o bool.cpp g++
Re: [PyQt] setCornerWidget for QMenuBar build Snapshots
On Wed, 07 Dec 2011 13:22:58 +0200, ad...@mbnoimi.net wrote: On 06/12/2011 09:32 م, Phil Thompson wrote: Snapshots are only provided as source packages I tried to build the snapshots as following but I failed... could you please help me in building process? Build steps: * Downloaded sip-4.13.1-snapshot-82af71f0adcb * Configured SIP then built it * Downloaded PyQt-win-gpl-snapshot-4.9-aea28dc027e5 * Configured PyQt * Downloaded NSIS * Run nsi Here's builing logs: --- SIP --- Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation. All rights reserved. C:UsersmbnoimiDesktopsip-4.13.1-snapshot-82af71f0adcbpath PATH=C:Python27Libsite-packagesPyQt4;C:Python27Libsite-packages;C:QtSDK mingwbin;C:Python27Scripts;C:Python27;C:Program FilesNVIDIA CorporationP hysXCommon;C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsS ystem32WindowsPowerShellv1.0;C:Program Filesdoxygenbin;C:Program FilesWi nMerge;C:Program FilesBazaar;C:Program FilesMicrosoft SQL Server100ToolsB inn;C:Program FilesMicrosoft SQL Server100DTSBinn C:UsersmbnoimiDesktopsip-4.13.1-snapshot-82af71f0adcbpython configure.py This is SIP 4.13.1-snapshot-82af71f0adcb for Python 2.7.2 on win32. The SIP code generator will be installed in C:Python27. The sip module will be installed in C:Python27Libsite-packages. The sip.h header file will be installed in C:Python27include. The default directory to install .sip files in is C:Python27sip. The platform/compiler configuration is win32-msvc2008. Creating siplibsip.h... Creating siplibsiplib.c... Creating siplibsiplib.sbf... Creating sipconfig.py... Creating top level Makefile... Creating sip code generator Makefile... Creating sip module Makefile... C:UsersmbnoimiDesktopsip-4.13.1-snapshot-82af71f0adcbpython configure.py -- platform win32-g++ This is SIP 4.13.1-snapshot-82af71f0adcb for Python 2.7.2 on win32. The SIP code generator will be installed in C:Python27. The sip module will be installed in C:Python27Libsite-packages. The sip.h header file will be installed in C:Python27include. The default directory to install .sip files in is C:Python27sip. The platform/compiler configuration is win32-g++. Creating siplibsip.h... Creating siplibsiplib.c... Creating siplibsiplib.sbf... Creating sipconfig.py... Creating top level Makefile... Creating sip code generator Makefile... Creating sip module Makefile... C:UsersmbnoimiDesktopsip-4.13.1-snapshot-82af71f0adcbminggw32-make 'minggw32-make' is not recognized as an internal or external command, operable program or batch file. C:UsersmbnoimiDesktopsip-4.13.1-snapshot-82af71f0adcbmingw32-make mingw32-make[1]: Entering directory `C:/Users/mbnoimi/Desktop/sip-4.13.1-snapsho t-82af71f0adcb/sipgen' makefile:29: warning: overriding commands for target `.c.o' makefile:26: warning: ignoring old commands for target `.c.o' gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -o main.o main.c gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -o transform.o trans form.c gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -o gencode.o gencode .c gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -o extracts.o extrac ts.c gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -o export.o export.c gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -o heap.o heap.c gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -o parser.o parser.c gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -o lexer.o lexer.c g++ -mthreads -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runt ime-pseudo-reloc -Wl,-subsystem,console -Wl,-s -o sip.exe main.o transform.o gen code.o extracts.o export.o heap.o parser.o lexer.o mingw32-make[1]: Leaving directory `C:/Users/mbnoimi/Desktop/sip-4.13.1-snapshot -82af71f0adcb/sipgen' mingw32-make[1]: Entering directory `C:/Users/mbnoimi/Desktop/sip-4.13.1-snapsho t-82af71f0adcb/siplib' makefile:29: warning: overriding commands for target `.c.o' makefile:26: warning: ignoring old commands for target `.c.o' gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -IC:Python27includ e -o siplib.o siplib.c gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -IC:Python27includ e -o apiversions.o apiversions.c gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -IC:Python27includ e -o descriptors.o descriptors.c gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -IC:Python27includ e -o qtlib.o qtlib.c gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -IC:Python27includ e -o threads.o threads.c gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -IC:Python27includ e -o objmap.o objmap.c gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -IC:Python27includ e -o voidptr.o voidptr.c g++ -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I.
Re: [PyQt] Subclass of QGraphicsObject does not have the correct class name listed in QGraphicsScene.items()
On Mon, 5 Dec 2011 18:01:25 -0500, Luke Campagnola lcamp...@email.unc.edu wrote: How about this: from PyQt4 import QtCore, QtGui import sip class GObject(QtGui.QGraphicsObject): def boundingRect(self): return QtCore.QRectF(0, 0, 10, 10) def paint(self, p, *args): p.drawRect(self.boundingRect()) app = QtGui.QApplication([]) scene = QtGui.QGraphicsScene() obj = GObject() scene.addItem(obj) items = scene.items(QtCore.QPointF(0,0)) objAddr = sip.unwrapinstance(sip.cast(obj, QtGui.QGraphicsItem)) itemAddr = sip.unwrapinstance(sip.cast(items[0], QtGui.QGraphicsItem)) print Adresses match:, objAddr == itemAddr print QGraphicsObject matches:, obj is items[0] That turned out to be easier than I thought - thanks for making me look at it in a different way. Try current SIP hg or tonight's snapshot. Phil On Mon, Dec 5, 2011 at 16:33, Phil Thompson p...@riverbankcomputing.com wrote: On Mon, 5 Dec 2011 12:24:57 -0500, Luke Campagnola lcamp...@email.unc.edu wrote: Howdy Phil, I'm running into this issue where QGraphicsScene.items() does not return the correct python objects if the items are subclassed from QGraphicsObject. Your response to this issue several months ago was: On Fri, May 20, 2011 at 11:46, Phil Thompson p...@riverbankcomputing.com wrote: It's because QGraphicsObject inherits both QObject and QGraphicsItem. items() returns a list of QGraphicsItems which, for a QGraphicsObject, has a different C++ address than the original QGraphicsObject. PyQt doesn't recognise that the QGraphicsItem is a cast of the QGraphicsObject. I don't think there is anything I can (sensibly) do about this. The workaround I am using for this bug is to maintain a dictionary that maps from the QtGui::QGraphicsItem memory address back to the original python object. Looks something like: cache[ sip.unwrapinstance(sip.cast(item, QtGui.QGraphicsItem)) ] = item This works, but it's rather messy since every instance of QGraphicsObject and QGraphicsWidget needs to register itself with this cache. I presume PyQt already maintains a similar dictionary so that it can translate between Qt's internal memory addresses and PyQt's wrapper objects. Would it not be straightforward to implement my workaround from within PyQt? Not straightforward, but certainly worth thinking about. Do you have something small I can use as a test case? Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Subclass of QGraphicsObject does not have the correct class name listed in QGraphicsScene.items()
Great, Thanks Phil! On Wed, Dec 7, 2011 at 07:56, Phil Thompson p...@riverbankcomputing.com wrote: On Mon, 5 Dec 2011 18:01:25 -0500, Luke Campagnola lcamp...@email.unc.edu wrote: How about this: from PyQt4 import QtCore, QtGui import sip class GObject(QtGui.QGraphicsObject): def boundingRect(self): return QtCore.QRectF(0, 0, 10, 10) def paint(self, p, *args): p.drawRect(self.boundingRect()) app = QtGui.QApplication([]) scene = QtGui.QGraphicsScene() obj = GObject() scene.addItem(obj) items = scene.items(QtCore.QPointF(0,0)) objAddr = sip.unwrapinstance(sip.cast(obj, QtGui.QGraphicsItem)) itemAddr = sip.unwrapinstance(sip.cast(items[0], QtGui.QGraphicsItem)) print Adresses match:, objAddr == itemAddr print QGraphicsObject matches:, obj is items[0] That turned out to be easier than I thought - thanks for making me look at it in a different way. Try current SIP hg or tonight's snapshot. Phil On Mon, Dec 5, 2011 at 16:33, Phil Thompson p...@riverbankcomputing.com wrote: On Mon, 5 Dec 2011 12:24:57 -0500, Luke Campagnola lcamp...@email.unc.edu wrote: Howdy Phil, I'm running into this issue where QGraphicsScene.items() does not return the correct python objects if the items are subclassed from QGraphicsObject. Your response to this issue several months ago was: On Fri, May 20, 2011 at 11:46, Phil Thompson p...@riverbankcomputing.com wrote: It's because QGraphicsObject inherits both QObject and QGraphicsItem. items() returns a list of QGraphicsItems which, for a QGraphicsObject, has a different C++ address than the original QGraphicsObject. PyQt doesn't recognise that the QGraphicsItem is a cast of the QGraphicsObject. I don't think there is anything I can (sensibly) do about this. The workaround I am using for this bug is to maintain a dictionary that maps from the QtGui::QGraphicsItem memory address back to the original python object. Looks something like: cache[ sip.unwrapinstance(sip.cast(item, QtGui.QGraphicsItem)) ] = item This works, but it's rather messy since every instance of QGraphicsObject and QGraphicsWidget needs to register itself with this cache. I presume PyQt already maintains a similar dictionary so that it can translate between Qt's internal memory addresses and PyQt's wrapper objects. Would it not be straightforward to implement my workaround from within PyQt? Not straightforward, but certainly worth thinking about. Do you have something small I can use as a test case? Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Menu icons missing in Xfce
On Wednesday 07 December 2011, 10:10:39 Mark Summerfield wrote: Hi, I have a Python 3/PyQt 4 application that has standard menus and toolbars and works fine under GNOME 2 on Debian 6. However, on Xubuntu (Xfce 4.8) the icons only show up in the toolbars not in the menus. Yet other applications (e.g., firefox, Archive Manager) have icons in their menus. Does anyone know the fix for this? Not really. Might be window manager related. How does other Qt-Apps appear (designer, assistant, ..)? Pete ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt