[PyQt] TypeError object of type int has no len issue

Baz Walter bazwal at ftml.net
Tue Sep 13 16:03:22 BST 2011

On 13/09/11 15:14, admin at mbnoimi.net wrote:
> Actually I asked for this issue in another thread but I faced a problem can't
> find any solution for it, so could you please help me to fix it?
> When I run the following class I get "TypeError object of type int has no len()"
> at for loop line 51. "messages" varialble is a list not int value... what's the
> problem here?

the signature for showSplash is:

     def showSplash(self, delay, messages, alignment, color):

but you're calling it with:

     splash.showSplash(0,  50, messages,  QColor(255,  255,  0))

you could have debugged this easily by adding the following line before 
the offending for loop:

     print type(messages), repr(messages)

also, if the for loop would be much better written as:

     for message in messages:
	# do stuff with message

or, if you need the index:

     for index, message in enumerate(messages):
	# do stuff with index and message


More information about the PyQt mailing list