<html style="direction: ltr;">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<style>body p { margin-bottom: 0cm; margin-top: 0pt; } </style>
<style>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 07/09/2011 11:27 م, Hans-Peter
Jansen wrote: </p>
<blockquote cite="mid:201109072227.38915.hpj@urpla.net" type="cite">
<pre wrap="">On Wednesday 07 September 2011, 14:04:02 <a class="moz-txt-link-abbreviated" href="mailto:admin@mbnoimi.net">admin@mbnoimi.net</a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">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 *
</pre>
</blockquote>
<pre wrap="">Hmm, that * imports are easily avoided.</pre>
</blockquote>
Thanks a lot Pete, You mean I don't need to use both import lines?<br>
<br>
<blockquote cite="mid:201109072227.38915.hpj@urpla.net" type="cite">
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">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):
</pre>
</blockquote>
<pre wrap="">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.</pre>
</blockquote>
I did as you mentioned exactly.<br>
I got new issue because I don't know how can I use QStringList
class, I read in some article that it's unavailable in PyQt so I
tried to use python lists instead but I got an exception at for loop
<br>
<pre><pre>TypeError object of type <font class="pastecode" color="#4682B4">int</font> has no len()</pre></pre>
here's the modified class:<br>
<pre><pre>from PyQt4.QtCore import *
from PyQt4.QtGui import *
import sys
<font class="pastecode" color="#FF0000">class</font> TeSplashScreen(QFrame):
<font class="pastecode" color="#008B00">""</font>"
Splash doc
<font class="pastecode" color="#008B00">""</font>"
app = QApplication(sys.argv)
sPixmap = QPixmap(10, 10)
sMessage = QString()
# messages = [<font class="pastecode" color="#008B00">"nothing"</font>]
sAlignment = 0
sColor = QColor()
def __init__(self, pixmap):
super(QFrame, self).__init__()
self.sPixmap = pixmap
self.setWindowFlags(Qt.FramelessWindowHint|Qt.WindowStaysOnTopHint)
self.setAttribute(Qt.WA_TranslucentBackground)
self.setFixedSize(self.sPixmap.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):
delay = 0
# self.messages = messages
alignment = 0
color = QColor(color)
<font class="pastecode" color="#FF0000">class</font> SleeperThread(QThread):
msecs = 0
QThread.msleep(msecs)
aSplashScreen = TeSplashScreen(self.sPixmap)
aSplashScreen.show
<font class="pastecode" color="#FF0000">for</font> i in range(len(messages)):
aSplashScreen.showMessage(messages[i], alignment, color)
SleeperThread.msleep(delay)</pre></pre>
<br>
<br>
<br>
-----<br>
Best Regards<br>
Muhammad Bashir Al-Noimi<br>
My Blog: <a class="moz-txt-link-freetext" href="http://mbnoimi.net">http://mbnoimi.net</a><br>
<br>
</body>
</html>