Hi Dan,

I wrote this example base on your example, and works very well.

from PySide.QtCore import QObject, Signal

class C(QObject):
   sig = Signal()

def foo():
   print 2

c = C()
c.sig.connect(foo)
c.sig.emit()

OUTPUT:
# python test.py
2


Which error do you get, when you try connect the signal? Can you send
the python back trace? Which version of pyside are you using?

BR



On Mon, Oct 4, 2010 at 6:16 PM, Dan Halbert <[email protected]> wrote:
> On Monday, October 4, 2010 4:41pm, "Dan Halbert" <[email protected]> said:
>>I tried to use new-style signals on the Ubuntu 0.4.1 pyside build:
>>from PySide.QtCore import *
>
>>sig = Signal()
>>def foo(): print 2
>>sig.connect(foo)
>
>>AttributeError: 'Signal' object has no attribute 'connect'
>
> Sorry! Never mind - my example was too simple. The Signal() has to be defined 
> in an class that inherits from QObject, and you have to instantiate such an 
> object:
>
> class C(QObject):
>    sig = Signal()
>
> def foo():
>    print 2
>
> c = C()
> # Note that: C.sig.connect(foo) does not work.
> c.sig.connect(foo)
>
> In my actual program which provoked the original email, I referred to a 
> signal by referencing it through the class, not the instance.
>
> _______________________________________________
> PySide mailing list
> [email protected]
> http://lists.openbossa.org/listinfo/pyside
>



-- 
Renato Araujo Oliveira Filho
Instituto Nokia de Tecnologia - INdT
Mobile: +55 (81) 8704-2144
_______________________________________________
PySide mailing list
[email protected]
http://lists.openbossa.org/listinfo/pyside

Reply via email to