[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyKDE] Python functions as slots
From:       Hans-Peter Jansen <hpj () urpla ! net>
Date:       2002-09-30 19:53:21
[Download RAW message or body]

Hi Konrad,

On Monday 30 September 2002 20:50, Konrad Hinsen wrote:
> I have lots of problems using Python functions as slots. As a simple
> illustration, take the following code (an example from Boudewijn Rempt's
> excellent book with an added connect):
>
>    import sys
>    from qt import *
>
>    def foo(*args):
>        print args
>
>    app=QApplication(sys.argv)
>    button=QPushButton("Hello World", None)
>    app.setMainWidget(button)
>    button.show()
>    app.connect(button, SIGNAL("clicked()"), app, foo)
>    app.exec_loop()

This is apparently wrong. Remove app arg from app.connect and 
all goes well. BTW: signal clicked does not take any arguments. 
If you want to pass some custom arguments with signals, roll 
your own (signals).

> When I run this code, I get:
>
>    Traceback (most recent call last):
>      File "hello1.py", line 14, in ?
>        app.connect(button, SIGNAL("clicked()"), app, foo)
>    TypeError: Argument 4 of QObject.connect() has an invalid type
>
> This doesn't always happen. For example, I can run the example
> "dial.py" from the same book without problems, although it uses Python
> methods as slots.
>
> In case it matters, I use PyQt 3.4 and Qt 2.3.1.
>
> Any idea what is happening here?
>
> Konrad.

BTW: Are you the Konrad "Signum" Hinsen?

Hans-Peter

_______________________________________________
PyKDE mailing list    PyKDE@mats.gmd.de
http://mats.gmd.de/mailman/listinfo/pykde
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic