[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: [PyQt] Need to draw rotating transparant image... without flickering!
From: Wim_ <wim12 () telenet ! be>
Date: 2007-12-30 23:27:56
Message-ID: 14552438.post () talk ! nabble ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Hello,
This is what I would like to do (simplified): I have 2 images (dome.png,
telescope.png) which are 100x100px, transparant and are meant to be painted
on top of each other, each rotated under a certain angle. These 2 angles can
vary with time, and I would like the painting on the screen to be updated
with these new angles, say at a frequency of once per second.
My solution (simplified):
class Painting(QWidget):
def __init__(self, *args):
self.domeAngle = 0
self.telescopeAngle = 0
apply(QWidget.__init__,(self, ) + args)
self.buffer = QPixmap()
self.setGeometry(0,0,100,100)
self.domeimage = QImage("dome.png")
self.telescopeimage = QImage("telescope.png")
def updateAngles(self,dome=None,telescope=None):
if dome: self.domeAngle = dome
if telescope: self.telescopeAngle = telescope
self.update()
def paintEvent(self, ev):
p = QPainter()
p.begin(self.buffer)
p.translate(50,50)
p.save()
p.rotate(self.telescopeAngle)
p.drawImage(QRect(-205,-205,410,410),self.telescopeimage)
p.restore()
p.save()
p.rotate(self.domeAngle)
p.drawImage(QRect(-205,-205,410,410),self.domeimage)
p.restore()
p.flush()
p.end()
bitBlt(self, 0, 0, self.buffer)
It works, but the problem is that it flickers! The current displayed
painting is "removed" at the first drawImage, and it takes until the bitBlt
before it is painted again! I have been trying a lot of other possibilities,
but they either give the same result, or strange "xlib" errors. The
environment where the code will run forces me to stick to QT3 so I hope it's
possible!
If anyone could help me with this I would be very very grateful, thank you
very much!
Wim (from Belgium)
--
View this message in context: \
http://www.nabble.com/Need-to-draw-rotating-transparant-image...-without-flickering%21-tp14552438p14552438.html
Sent from the PyQt mailing list archive at Nabble.com.
[Attachment #5 (text/html)]
<p>Hello,</p>
<p>This is what I would like to do (simplified): I have 2 images (dome.png, \
telescope.png) which are 100x100px, transparant and are meant to be painted on top of \
each other, each rotated under a certain angle. These 2 angles can vary with time, \
and I would like the painting on the screen to be updated with these new angles, say \
at a frequency of once per second.</p>
<p>My solution (simplified):</p>
<p>
<pre>
class Painting(QWidget):
def __init__(self, *args):
self.domeAngle = 0
self.telescopeAngle = 0
apply(QWidget.__init__,(self, ) + args)
self.buffer = QPixmap()
self.setGeometry(0,0,100,100)
self.domeimage = QImage("dome.png")
self.telescopeimage = QImage("telescope.png")
def updateAngles(self,dome=None,telescope=None):
if dome: self.domeAngle = dome
if telescope: self.telescopeAngle = telescope
self.update()
def paintEvent(self, ev):
p = QPainter()
p.begin(self.buffer)
p.translate(50,50)
p.save()
p.rotate(self.telescopeAngle)
p.drawImage(QRect(-205,-205,410,410),self.telescopeimage)
p.restore()
p.save()
p.rotate(self.domeAngle)
p.drawImage(QRect(-205,-205,410,410),self.domeimage)
p.restore()
p.flush()
p.end()
bitBlt(self, 0, 0, self.buffer)
</pre>
</p>
<p>It works, but the problem is that it flickers! The current displayed painting is \
"removed" at the first drawImage, and it takes until the bitBlt before it is painted \
again! I have been trying a lot of other possibilities, but they either give the same \
result, or strange "xlib" errors. The environment where the code will run forces me \
to stick to QT3 so I hope it's possible! </p>
<p>If anyone could help me with this I would be very very grateful, thank you very \
much!</p> <p>Wim (from Belgium)</p>
<br><hr align="left" width="300">
View this message in context: <a \
href="http://www.nabble.com/Need-to-draw-rotating-transparant-image...-without-flickering%21-tp14552438p14552438.html">Need \
to draw rotating transparant image... without flickering!</a><br> Sent from the <a \
href="http://www.nabble.com/PyQt-f23444.html">PyQt mailing list archive</a> at \
Nabble.com.<br>
_______________________________________________
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