[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] About paintEvent and semi-transparent background pixmap.
From:       "=?ISO-8859-1?Q?Gustavo_A._D=EDaz?=" <gustavo.diaz () gmail ! com>
Date:       2007-08-27 17:58:21
Message-ID: 64c123920708271058l359feabcu350a304528608474 () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi!!

Still i am trying to solve the semi-transparent backrground for my app,
which i've done this so far:

...
def showEvent(self, event):
        self.desktopBg =
QtGui.QPixmap.grabWindow(QApplication.desktop().winId(),
\
                self.geometry().x(),self.geometry().y(), self.rect().width(),
self.rect().height())

    def paintEvent (self, event):
        self.clientBgPixmap = QtGui.QPixmap
(":/Pixmaps/pixmaps/oc_clientBg.png")
        self.setMask(self.clientBgPixmap.mask())
        self.painter = QtGui.QPainter(self)
        self.painter.setRenderHint(QPainter.Antialiasing)
        self.painter.drawPixmap(0, 0, self.desktopBg)
        self.painter.drawPixmap(0, 0, self.clientBgPixmap)
        self.painter.end()
...

So i got a semi-transparent background (and of course,  the .png pixmap is
semi-transparent) but it only refresh what shines trough the background when
I hide and show my app (from my systray).

I've implemented too the drag and drop event so i could move my app with the
left button of the mouse:

def mousePressEvent(self, event):
            if event.button() == QtCore.Qt.LeftButton:
                    self.dragPosition = event.globalPos() -
self.frameGeometry().topLeft()
            event.accept()

        def mouseMoveEvent(self, event):
            if event.buttons() == QtCore.Qt.LeftButton:
                    self.move(event.globalPos() - self.dragPosition)
            event.accept()


Now, my question is, how i could update what shines trough the background
pixmap when i drop my app? (not necessary when i move it, just when i drop
it)

Thanks!!

Cheers.


-- 
Gustavo A. Díaz
GDNet Projects
www.gdnet.com.ar

[Attachment #5 (text/html)]

Hi!!<br><br>Still i am trying to solve the semi-transparent backrground for my app, \
which i&#39;ve done this so far:<br><br>...<br>def showEvent(self, \
event):<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; self.desktopBg = \
QtGui.QPixmap.grabWindow(QApplication.desktop ().winId(), \<br>&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \
self.geometry().x(),self.geometry().y(), self.rect().width(), \
self.rect().height())<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; def paintEvent \
(self, event):<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; self.clientBgPixmap = \
QtGui.QPixmap(&quot;:/Pixmaps/pixmaps/oc_clientBg.png&quot;) <br>&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp; self.setMask(self.clientBgPixmap.mask())<br>&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp; self.painter = QtGui.QPainter(self)<br>&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp; self.painter.setRenderHint(QPainter.Antialiasing)<br>&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp; self.painter.drawPixmap(0, 0, self.desktopBg)<br> \
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; self.painter.drawPixmap(0, 0, \
self.clientBgPixmap)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; self.painter.end()<br \
clear="all">...<br><br>So i got a semi-transparent background (and of course,&nbsp; \
the .png pixmap is semi-transparent) but it only refresh what shines trough the \
background when I hide and show my app (from my systray). <br><br>I&#39;ve \
implemented too the drag and drop event so i could move my app with the left button \
of the mouse:<br><br>def mousePressEvent(self, \
event):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if \
event.button() == QtCore.Qt.LeftButton:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;  self.dragPosition = event.globalPos() - \
self.frameGeometry().topLeft()<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp; event.accept()<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; def \
mouseMoveEvent(self, event):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp; if event.buttons() == \
QtCore.Qt.LeftButton:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;  self.move(event.globalPos() - \
self.dragPosition)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \
event.accept()<br><br><br>Now, my question is, how i could update what shines trough \
the background pixmap when i drop my app? (not necessary when i move it, just when i \
drop it) <br><br>Thanks!!<br><br>Cheers.<br><br><br>-- <br>Gustavo A. Díaz<br>GDNet \
Projects<br><a href="http://www.gdnet.com.ar">www.gdnet.com.ar</a>



_______________________________________________
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