[PyQt] unexpected behavior from winId() and QSpacerItem

2008-08-19 Thread Brian Parma
Ok, so I was making a simple widget that had a little 32x32 png image 
that you can pick up and move around.  I do this by setting the mouse 
cursor to a pixmap cursor of the image when mousePressEvent is 
triggered, and reverting back when mouseReleaseEvent is triggered.  I 
also want to track the mouse with mouseMoveEvent for later 
functionality.  For the functionality I want, the mouse needs to 
continue to be tracked when it leaves the widget/window (and hopefully 
keeps the icon).  This was easier to get working than I had thought, but 
when I started adding functionality and incorporated it into a window I 
ran into some strange behavior.  If I have my widget in a gridLayout 
with a QSpacerItem with a QSizePolicy.Expanding property and also call 
winId() for my widget, the tracking/cursor break when the mouse goes out 
of the window.  The behavior is even different I move the mouse out the 
top vs. out the sides and bottom, as the former doesn't even resume 
tracking when the mouse comes back onto the window. 

The appended code reproduces the behavior (I'm using PyQt4.4.3 and 
Python2.5.2, on WindowsXP Pro). 

If you comment out the call to self.winId(), than the code works as 
expected.  Also, if you leave the call to self.winId() but remove the 
,QtGui.QSizePolicy.Expanding from the QSpacerItem constructor the code 
works correctly.  It seems that having both of them breaks something.  
Is this a Bug, or am I just missing something?




from PyQt4 import QtGui, QtCore
import sys

class Drag(QtGui.QLabel):
   def __init__(self, parent=None):
   QtGui.QLabel.__init__(self, parent)
   self.image = QtGui.QPixmap('dead.png')
   self.wfc = QtGui.QCursor(self.image)
   self.setPixmap(self.image)
   self.winId()
  
   def mousePressEvent(self, event):

   print 'set'
   self.setPixmap(QtGui.QPixmap())
   self.setCursor(self.wfc)
   event.accept()
  
   def mouseMoveEvent(self, event):

   print event.pos()
   event.accept()

   def mouseReleaseEvent(self, event):
   print 'rel'
   self.setCursor(QtCore.Qt.ArrowCursor)
   self.setPixmap(self.image)
   event.accept()


if __name__ == '__main__':
   app = QtGui.QApplication(sys.argv)
   win = QtGui.QWidget()
   lay = QtGui.QGridLayout(win)
   dw = Drag(win)
   lay.addWidget(dw)
   lay.addItem(QtGui.QSpacerItem(13,20,QtGui.QSizePolicy.Expanding), 1, 1)
   win.show()
   win.resize(200,200)
  
   app.exec_()


from PyQt4 import QtGui, QtCore
import sys

class Drag(QtGui.QLabel):
def __init__(self, parent=None):
QtGui.QLabel.__init__(self, parent)
self.image = QtGui.QPixmap('dead.png')
self.wfc = QtGui.QCursor(self.image)
self.setPixmap(self.image)
self.winId()

def mousePressEvent(self, event):
print 'set'
self.setPixmap(QtGui.QPixmap())
self.setCursor(self.wfc)
event.accept()

def mouseMoveEvent(self, event):
print event.pos()
event.accept()

def mouseReleaseEvent(self, event):
print 'rel'
self.setCursor(QtCore.Qt.ArrowCursor)
self.setPixmap(self.image)
event.accept()
  

if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
win = QtGui.QWidget()
lay = QtGui.QGridLayout(win)
dw = Drag(win)
lay.addWidget(dw)
lay.addItem(QtGui.QSpacerItem(13,20,QtGui.QSizePolicy.Expanding), 1, 1)
win.show()
win.resize(200,200)

app.exec_()
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Re: Auto-generate sip specification file?

2008-08-19 Thread Simon Edwards

Kevin Watters wrote:
I'm still at Akademy, but I'll try to get this checked into KDE's SVN 
some time this weekend along with all of my changes. (Probably in 
kdesupport. I'm not sure if I can keep the change history though.)


+1 on interest in seeing this! Especially the autodocs-from-doxygen support.


That part is probably one of the more dubious ones, especially now that 
I've hacked a bunch of extra stuff on to it.


Anyway, twine is now in KDE's subversion repository in kdesupport:

http://websvn.kde.org/trunk/kdesupport/twine/

There are currently no docs for it though and it is a bit too KDE 4 
specific in places too. But you're welcome to have a look at it.


cheers,

--
Simon Edwards | KDE-NL, Guidance tools, Guarddog Firewall
[EMAIL PROTECTED]   | http://www.simonzone.com/software/
Nijmegen, The Netherlands | ZooTV? You made the right choice.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] Compiling PyQt on Mac OS X

2008-08-19 Thread Daniel Miller

I'm having problems compiling PyQt on Mac OS X.


Library versions:

Mac OS X 10.4.11
Python 2.5.1
qt-mac-opensource-src-4.4.1
PyQt-mac-gpl-4.4.3
sip-4.7.8-snapshot-20080817


Commands used to compile SIP:

$ python configure.py -n -s MacOSX10.4u.sdk
$ make


Commands used to compile Qt:

$ ./configure -release -nomake examples -nomake demos -no-qdbus - 
universal -no-framework

$ make
$ sudo make install


Commands used to compile PyQt (this is where the problems start):

$ python configure.py -q /usr/local/Trolltech/Qt-4.4.1/bin/qmake -e  
QtCore -e QtGui


Results in the following output:

Determining the layout of your Qt installation...
This is the GPL version of PyQt 4.4.3 (licensed under the GNU General  
Public

License) for Python 2.5.1 on darwin.

Type '2' to view the GPL v2 license.
Type '3' to view the GPL v3 license.
Type 'yes' to accept the terms of the license.
Type 'no' to decline the terms of the license.

Do you accept the terms of the license? yes
Checking to see if the QtGui module should be built...
QtDesigner module disabled with universal binaries.
Qt v4.4.1 free edition is being used.
SIP 4.7.8-snapshot-20080817 is being used.
The Qt header files are in /usr/local/Trolltech/Qt-4.4.1/include.
The shared Qt libraries are in /usr/local/Trolltech/Qt-4.4.1/lib.
The Qt binaries are in /usr/local/Trolltech/Qt-4.4.1/bin.
The Qt mkspecs directory is in /usr/local/Trolltech/Qt-4.4.1.
These PyQt modules will be built: QtCore QtGui.
The PyQt Python package will be installed in
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site- 
packages.

The Designer plugin will be installed in
/usr/local/Trolltech/Qt-4.4.1/plugins/designer.
The PyQt .sip files will be installed in
/Library/Frameworks/Python.framework/Versions/2.5/share/sip/PyQt4.
pyuic4, pyrcc4 and pylupdate4 will be installed in
/Library/Frameworks/Python.framework/Versions/2.5/bin.
Generating the C++ source for the QtCore module...
sip: sip/QtCore/qtimer.sip:54: SIP_RXOBJ_CON and SIP_SLOT_CON must  
both be given and at most once

Error: Unable to create the C++ code.


So I changed qtimer.sip line  54 from this:

static void singleShot(int msec, SIP_RXOBJ_CON receiver / 
SingleShot/, SIP_SLOT_CON() member) ...


to this:

static void singleShot(int msec, SIP_RXOBJ_CON, SIP_SLOT_CON()) ...


And run configure again, which results in this output:

Determining the layout of your Qt installation...
This is the GPL version of PyQt 4.4.3 (licensed under the GNU General  
Public

License) for Python 2.5.1 on darwin.

Type '2' to view the GPL v2 license.
Type '3' to view the GPL v3 license.
Type 'yes' to accept the terms of the license.
Type 'no' to decline the terms of the license.

Do you accept the terms of the license? yes
Checking to see if the QtGui module should be built...
QtDesigner module disabled with universal binaries.
Qt v4.4.1 free edition is being used.
SIP 4.7.8-snapshot-20080817 is being used.
The Qt header files are in /usr/local/Trolltech/Qt-4.4.1/include.
The shared Qt libraries are in /usr/local/Trolltech/Qt-4.4.1/lib.
The Qt binaries are in /usr/local/Trolltech/Qt-4.4.1/bin.
The Qt mkspecs directory is in /usr/local/Trolltech/Qt-4.4.1.
These PyQt modules will be built: QtCore QtGui.
The PyQt Python package will be installed in
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site- 
packages.

The Designer plugin will be installed in
/usr/local/Trolltech/Qt-4.4.1/plugins/designer.
The PyQt .sip files will be installed in
/Library/Frameworks/Python.framework/Versions/2.5/share/sip/PyQt4.
pyuic4, pyrcc4 and pylupdate4 will be installed in
/Library/Frameworks/Python.framework/Versions/2.5/bin.
Generating the C++ source for the QtCore module...
Creating the Makefile for the QtCore module...
Generating the C++ source for the QtGui module...
sip: sip/QtGui/qapplication.sip:42: syntax error
Error: Unable to create the C++ code.


So I commented out the '%If (WS_X11) ...' block in qapplication.sip  
(since I'm not compiling against X11, and that block seems to be the  
holdup). At this point the configure succeeds. So I go on to the next  
step:


$ make
make[1]: Nothing to be done for `all'.
g++ -c -pipe -fPIC -arch ppc -arch i386 -isysroot /Developer/SDKs/ 
MacOSX10.4u.sdk -Os -Wall -W -DQT_NO_DEBUG -DQT_CORE_LIB -I. -I/ 
Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 -I/ 
usr/local/Trolltech/Qt-4.4.1/mkspecs/default -I/usr/local/Trolltech/ 
Qt-4.4.1/include/QtCore -I/usr/local/Trolltech/Qt-4.4.1/include -o  
sipQtCorecmodule.o sipQtCorecmodule.cpp
sip/QtCore/qobject.sip: In function 'int qtcore_py_to_qt_cpp 
(PyObject*, const sipSigArg*, void*)':
sip/QtCore/qobject.sip:1033: error: 'sipAssignInstance' was not  
declared in this scope
sip/QtCore/qobject.sip:1064: error: 'sipAssignMappedType' was not  
declared in this scope
sip/QtCore/qobject.sip: In function 'int qtcore_py_to_qt_cpp 
(PyObject*, const sipSigArg*, void*)':
sip/QtCore/qobject.sip:1033: error: