On 13/09/2011 06:03 م, Baz Walter wrote:

On 13/09/11 15:14, ad...@mbnoimi.net wrote:

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

Thanks,


I fixed the class and now it's working well. You can find it in the attachment.

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

Reply via email to