Hi Phil

I have this code, which I hoped would work:

    ...
           for i in xrange(3):
               lev = LevelUI(container)

               curried = partial(self.on_level_price_valueChanged, lev)
               QObject.connect(lev.price, SIGNAL("valueChanged(double)"),
                               curried)

   ...
   def on_level_price_valueChanged(self, level, value):
         ...


Unfortunately, partial does not seem to be recognized by connect(). This is a
workaround to create a closure with in-place evaluation of 'lev' (note the
keyword arg l=lev)::

           for i in xrange(3):
               lev = LevelUI(container)

               QObject.connect(lev.price, SIGNAL("valueChanged(double)"),
                               lambda x, l=lev:
self.on_level_price_valueChanged(l, x))

but really, wouldn't it be nicer if partial() was supported?

cheers,
_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to