Re: [PyQt] Bug in sip-4.11.1 and PyQt-4.7.7 ?

2010-09-28 Thread Baz Walter

On 27/09/10 19:45, Gerard Vermeulen wrote:

  Phil,

when running the following code

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import PyQt4.Qt as Qt

class MyWidget(Qt.QWidget):

 def __init__(self, parent=None):
 super(Qt.QWidget, self).__init__(parent)

  # __init__()

# class MyWidget

def bar(widget):
 pass

# bar()

def foo(widget):
 print type(widget)
 # BUG? For me widget is a Python type, but not for widget.connect().
 widget.connect(widget, Qt.SIGNAL('item_changed(widget)'), bar)


item_changed is a new PyQt4 signal defined dynamically. so you need to 
write either:


  widget.connect(widget, Qt.SIGNAL('item_changed'), bar)

or possibly:

  widget.connect(widget, Qt.SIGNAL('item_changed(PyQt_PyObject)'), bar)

you would then emit item_changed like this:

  widget.emit(Qt.SIGNAL('item_changed'), widget)

or:

  widget.emit(Qt.SIGNAL('item_changed(PyQt_PyObject)'), widget)

see here for more details:

http://www.riverbankcomputing.com/static/Docs/PyQt4/pyqt4ref.html#pyqt-signals-and-qt-signals


# foo()

if __name__ == '__main__':
 application = Qt.QApplication([])
 widget = MyWidget()
 foo(widget)

# Local Variables: ***
# mode: python ***
# End: ***

I get this traceback:

class '__main__.MyWidget'
Traceback (most recent call last):
   File bug.py, line 31, inmodule
 foo(widget)
   File bug.py, line 23, in foo
 widget.connect(widget, Qt.SIGNAL('item_changed(widget)'), bar)
TypeError: C++ type 'widget' is not supported as a slot argument type

but isn't widget a Python type? (although derived from a C++ type)


no. widget is an instance of class MyWidget, not a type.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] Bug in sip-4.11.1 and PyQt-4.7.7 ?

2010-09-27 Thread Gerard Vermeulen
 Phil,

when running the following code

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import PyQt4.Qt as Qt

class MyWidget(Qt.QWidget):
   
def __init__(self, parent=None):
super(Qt.QWidget, self).__init__(parent)

 # __init__()

# class MyWidget

def bar(widget):
pass

# bar()

def foo(widget):
print type(widget)
# BUG? For me widget is a Python type, but not for widget.connect().
widget.connect(widget, Qt.SIGNAL('item_changed(widget)'), bar)

# foo()

if __name__ == '__main__':
application = Qt.QApplication([])
widget = MyWidget()
foo(widget)

# Local Variables: ***
# mode: python ***
# End: ***

I get this traceback:

class '__main__.MyWidget'
Traceback (most recent call last):
  File bug.py, line 31, in module
foo(widget)
  File bug.py, line 23, in foo
widget.connect(widget, Qt.SIGNAL('item_changed(widget)'), bar)
TypeError: C++ type 'widget' is not supported as a slot argument type

but isn't widget a Python type? (although derived from a C++ type)

Best regards -- Gerard

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Bug in sip-4.11.1 and PyQt-4.7.7 ?

2010-09-27 Thread Vicente Sole

Hi Gerard,

Quoting Gerard Vermeulen gav...@gmail.com:


 Phil,

when running the following code

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import PyQt4.Qt as Qt

class MyWidget(Qt.QWidget):

def __init__(self, parent=None):
super(Qt.QWidget, self).__init__(parent)



Just for my information, what is the difference between:

super(Qt.QWidget, self).__init__(parent)

and:

Qt.QWidget.__init__(self, parent)

I have never used super() and never found the reported problem but  
I do not have very recent versions of sip and PyQt installed.


Best regards,

Armando
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Bug in sip-4.11.1 and PyQt-4.7.7 ?

2010-09-27 Thread Darren Dale
On Mon, Sep 27, 2010 at 2:45 PM, Gerard Vermeulen gav...@gmail.com wrote:
  Phil,

 when running the following code

 #!/usr/bin/env python
 # -*- coding: utf-8 -*-

 import PyQt4.Qt as Qt

 class MyWidget(Qt.QWidget):

    def __init__(self, parent=None):
        super(Qt.QWidget, self).__init__(parent)

That should be super(MyWidget, self).__init__(parent).

Darren
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Bug in sip-4.11.1 and PyQt-4.7.7 ?

2010-09-27 Thread Darren Dale
On Mon, Sep 27, 2010 at 3:02 PM, Vicente Sole s...@esrf.fr wrote:
 Hi Gerard,

 Quoting Gerard Vermeulen gav...@gmail.com:

  Phil,

 when running the following code

 #!/usr/bin/env python
 # -*- coding: utf-8 -*-

 import PyQt4.Qt as Qt

 class MyWidget(Qt.QWidget):

    def __init__(self, parent=None):
        super(Qt.QWidget, self).__init__(parent)


 Just for my information, what is the difference between:

 super(Qt.QWidget, self).__init__(parent)

 and:

 Qt.QWidget.__init__(self, parent)

The example should have read: super(MyWidget,
self).__init__(parent), not super(Qt.QWidget,
self).__init__(parent). In this example, there is no difference
between the two syntaxes, but in cases involving multiple inheritance,
super() returns a proxy that delegates calls to the appropriate
superclass, as determined by the method resolution order. More here:
http://docs.python.org/library/functions.html#super

Darren
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Bug in sip-4.11.1 and PyQt-4.7.7 ?

2010-09-27 Thread Hans-Peter Jansen
On Monday 27 September 2010, 21:17:35 Darren Dale wrote:
 On Mon, Sep 27, 2010 at 3:02 PM, Vicente Sole s...@esrf.fr wrote:
  Hi Gerard,
 
  Quoting Gerard Vermeulen gav...@gmail.com:
   Phil,
 
  when running the following code
 
  #!/usr/bin/env python
  # -*- coding: utf-8 -*-
 
  import PyQt4.Qt as Qt
 
  class MyWidget(Qt.QWidget):
 
     def __init__(self, parent=None):
         super(Qt.QWidget, self).__init__(parent)
 
  Just for my information, what is the difference between:
 
  super(Qt.QWidget, self).__init__(parent)
 
  and:
 
  Qt.QWidget.__init__(self, parent)

 The example should have read: super(MyWidget,
 self).__init__(parent), not super(Qt.QWidget,
 self).__init__(parent). In this example, there is no difference
 between the two syntaxes, but in cases involving multiple inheritance,
 super() returns a proxy that delegates calls to the appropriate
 superclass, as determined by the method resolution order. More here:
 http://docs.python.org/library/functions.html#super

...and you can't inherit from more then one QObject derived class because 
sip does not support multiple inheritance.

The major difference for the user is easier refactoring, as the parent class 
only needs to be mentioned once..

One downside of using super is, that it's only feasible for Python's new 
style classes.

Pete
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt