[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Re: [PyQt] TypeError object of type int has no len issue
From: Muhammad Bashir Al-Noimi <admin () mbnoimi ! net>
Date: 2011-09-16 20:42:42
Message-ID: 4E73B4C2.4070300 () mbnoimi ! net
[Download RAW message or body]
[Attachment #2 (text/html)]
<html style="direction: ltr;">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<style type="text/css">body p { margin-bottom: 0cm; margin-top: 0pt; } </style>
<style type="text/css">body p { margin-bottom: 0cm; margin-top: 0pt; } </style>
</head>
<body style="direction: ltr;"
bidimailui-detected-decoding-type="UTF-8" bgcolor="#FFFFFF"
text="#000000">
<p><font face="Tahoma"></font>On 13/09/2011 06:03 م, Baz Walter
wrote: </p>
<blockquote cite="mid:4E6F70BA.5080402@ftml.net" type="cite">On
13/09/11 15:14, <a class="moz-txt-link-abbreviated"
href="mailto:admin@mbnoimi.net">admin@mbnoimi.net</a> wrote: <br>
<br>
the signature for showSplash is: <br>
<br>
def showSplash(self, delay, messages, alignment, color): <br>
<br>
but you're calling it with: <br>
<br>
splash.showSplash(0, 50, messages, QColor(255, 255, 0)) <br>
<br>
you could have debugged this easily by adding the following line
before the offending for loop: <br>
<br>
print type(messages), repr(messages) <br>
<br>
also, if the for loop would be much better written as: <br>
<br>
for message in messages: <br>
# do stuff with message <br>
<br>
or, if you need the index: <br>
<br>
for index, message in enumerate(messages): <br>
# do stuff with index and message </blockquote>
<p>Thanks, </p>
<p><br>
</p>
<p>I fixed the class and now it's working well. You can find it in
the attachment.</p>
<p> </p>
</body>
</html>
["tesplashscreen.py" (text/plain)]
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import sys
class TeSplashScreen(QFrame):
"""
Splash doc
"""
app = QApplication(sys.argv)
sPixmap = QPixmap(10, 10)
sMessage = QString("")
sAlignment = 0
sColor = QColor(255, 255, 0)
def __init__(self, pixmap):
super(QFrame, self).__init__()
self.sPixmap = pixmap
self.setWindowFlags(Qt.FramelessWindowHint|Qt.WindowStaysOnTopHint)
self.setAttribute(Qt.WA_TranslucentBackground)
self.setFixedSize(pixmap.size())
def clearMessage(self):
self.sMessage.clear()
self.repaint()
def showMessage(self, theMessage, theAlignment, theColor):
self.sMessage = theMessage
self.sAlignment = theAlignment
self.sColor = theColor
self.repaint()
def paintEvent(self, pe):
aTextRect = QRect(self.rect())
aTextRect.setRect(aTextRect.x()+5, aTextRect.y()+5, aTextRect.width()-10, aTextRect.height()-10)
aPainter = QPainter(self)
aPainter.drawPixmap(self.rect(), self.sPixmap)
aPainter.setPen(self.sColor)
aPainter.drawText(aTextRect, self.sAlignment, self.sMessage)
def showSplash(self, delay, messages, alignment, color):
class SleeperThread(QThread):
msecs = 0
QThread.msleep(msecs)
aSplashScreen = TeSplashScreen(self.sPixmap)
aSplashScreen.show()
for i in range(len(messages)):
aSplashScreen.showMessage(messages[i], self.sAlignment, color)
SleeperThread.msleep(delay)
def showSplash(self, delaies, defaultDelay, messages, alignment, color):
class SleeperThread(QThread):
msecs = 0
QThread.msleep(msecs)
aSplashScreen = TeSplashScreen(self.sPixmap)
aSplashScreen.show()
for i in range(len(messages)):
aSplashScreen.showMessage(messages[i], self.sAlignment, color)
if i<len(delaies):
SleeperThread.msleep(delaies[i])
else:
SleeperThread.msleep(defaultDelay)
# def showSplash(delay, messages, alignment, color):
# delay = 0
# messages = QStringList()
# alignment = 0
# color = QColor()
# class SleeperThread(QThread):
# msecs = 0
# QThread.msleep(msecs)
# aSplashScreen = TeSplashScreen(sPixmap)
# aSplashScreen.show()
# for i in range(messages.count()):
# aSplashScreen.showMessage(messages[i], alignment, color)
# SleeperThread.msleep(delay)
_______________________________________________
PyQt mailing list PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic