[PyQt] Changing the opacity of a frame when it doesn't have the focus

projetmbc projetmbc at club-internet.fr
Fri Apr 10 11:43:20 BST 2009


Sorry for the indentation of the code but the problem is not there.

My problem is that nothing is printed when the focus of the frame changes.

Christophe.



> Hello,
> I would like to catch the events when my frame has the focus or losts 
> it. I don't understand why the following code doesn't work. Indeed, I 
> would like the frame to have a 0.5 opacity when the focus is out and 
> 1.0 when it is in the frame.
>
> Every tip or clue is welcome.
> Christophe.
>
> ==========
> THE CODE
> ==========
>
> class MyFrame(QtGui.QFrame):
>    def __init__(self, parent, titre, pixmapfile):
>        QtGui.QFrame.__init__(self, parent, QtCore.Qt.Tool)
>        self.setWindowTitle(titre)
>        rect = QtCore.QRect(QtGui.QCursor.pos(), pixmapfile.size())
>        self.setGeometry(rect)
>        self.setFixedSize(pixmapfile.size())
>
>        label = QtGui.QLabel(self)
>        label.setPixmap(pixmapfile)
>        label.show()
>
>        self.timer = QtCore.QTimer()
>              self.connect( self.timer, QtCore.SIGNAL("timeout()"), 
> self, QtCore.SLOT("hide()"))
>
>    def focusOutEvent(self, evt):
>        print 'out'
>      def focusInEvent(self, evt):
>        print 'in'
>
>    def showEvent(self, evt):
>        self.timer.start(10000) # 10 seconds
>        QtGui.QFrame.showEvent(self, evt)
>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
>
>




More information about the PyQt mailing list