[PyKDE] List confusion
Derek Fountain
derekfountain at yahoo.co.uk
Wed Sep 24 09:22:01 BST 2003
This might be a general Python newbie question. But it's confusing me in a
PyQt context. :o)
I have a slot in a class which receives a list of images. It adds that list to
it's existing list, then sends off a signal saying the existing list has
changed:
currentImageList = []
def slotInsertImages( self, imageList ):
self.currentImageList.extend( imageList )
self.emit( PYSIGNAL("signalUpdateImageList"), self.currentImageList )
This doesn't work. I get an error saying:
TypeError: Argument 2 of QObject.emit() has an invalid type
Changing the "self.currentImageList" to "(self.currentImageList,)" makes it
work.
On the other end of that signal is a slot which looks like this:
def slotUpdateImageList( self, imageList ):
print "update image list"
for file in imageList:
print file
Which also works. :o)
What I don't understand is why I need to force the currentImageList into a
tuple with one item - that item being my list of image names. What is
received at the other end is clearly a list since I can loop over it. It
feels like the slot should have to take the first index of its 'imageList'
argument, but that's clearly not the case.
What's going on? What does the self.emit() method actually do with it's second
argument?
--
> eatapple
core dump
More information about the PyQt
mailing list