[PyKDE] menu/actions questions

Phil Thompson phil at river-bank.demon.co.uk
Wed Feb 12 15:33:01 GMT 2003


On Wednesday 12 February 2003 1:52 pm, Garry Hodgson wrote:
> i'm trying to create a menu of mail folders for a mail client
> i'm writing.  results so far are good, but i'm a bit mystified
> about how to get menus to do what i want.  so, a couple of
> questions:
>
> 1.
> in the following code, i create two menu items, "Test 1" and "Test 2".
> i insert them into a menu, attaching a function to each.  if i run the
> app,
> test 1 works, but test 2 silently fails.  no error, just no action.
> if i assign the lambda expression to a var, and run it, it does what
> i'd expect.  but apparently some magic is happening behind the scenes.

PyQt doesn't increase the reference count of objects passed as slots, so a 
lambda function will get garbage collected unless you explicitly save it 
somewhere.

Phil




More information about the PyQt mailing list