[PyQt] Delaying splash screen
Hans-Peter Jansen
hpj at urpla.net
Wed Sep 7 21:27:38 BST 2011
On Wednesday 07 September 2011, 14:04:02 admin at mbnoimi.net wrote:
> Hi guys,
>
> I wrote a tiny class for delaying splash screen in C++ but when I
> tired to re-write it in python it didn't work!
>
> I got "AttributeError TeSplashScreen object has no attribut QFrate"
> although TeSplashScreen inherited from QFrame
>
> Could you please help me, I'm still a newbie in PyQt and Python.
>
> tesplashscreen.py
>
> from PyQt4.QtCore import *
> from PyQt4.QtGui import *
Hmm, that * imports are easily avoided.
> import sys
> class TeSplashScreen(QFrame):
> """
> Splash doc
> """
>
> app = QApplication(sys.argv)
> sPixmap = QPixmap(10, 10)
> sMessage = QString()
> messages = ["nothing"]
> sAlignment = 0
> sColor = QColor()
>
> def __init__(self, pixmap):
You need to call the base class c'tor here, e.g.:
super(QFrame, self).__init__()
Most of your code below has issues with missing self. references, which
will result in access to undefined variables and instances, that are
prematurely garbarge collected.
> self.sPixmap = pixmap
> self.QFrame(self,
> Qt.FramelessWindowHint|Qt.WindowStaysOnTopHint)
> self.setAttribute(Qt.WA_TranslucentBackground)
> self.setFixedSize(sPixmap.size())
^
>
> def clearMessage(self):
> sMessage.clear()
^
> repaint()
^
>
> def showMessage(self, theMessage, theAlignment, theColor):
> self.sMessage = theMessage
> self.sAlignment = theAlignment
> self.sColor = theColor
> repaint()
^
and so on...
Pete
More information about the PyQt
mailing list