[PyQt] window background

Kerri Reno kreno at yumaed.org
Wed Mar 21 19:51:50 GMT 2007


I'm trying to put our system logo in the background of our main window.
It works fine on Windows XP, but on Linux, the image flashes on the
screen, and then goes black.  The palette is set to a white brush with a
pixmap.  Below is example code containing the attached x.jpg.  I hope
someone out there has an idea, this is driving me nuts!  (it flashes
really quickly with such a small jpg, if you want a bigger one, let me know)

Thanks in advance,
Kerri

-----------------code here--------------------------------------------
#!/usr/bin/env python
# vim:set ts=4:set ff=unix

import sys
from PyQt4 import QtGui, QtCore

class MainWindow(QtGui.QMainWindow):

     def __init__(self):
         QtGui.QMainWindow.__init__(self)

         self.resize(QtCore.QSize(QtCore.QRect(0,0,800,600).size()).expan
dedTo(self.minimumSizeHint()))

         self.setMinimumSize(QtCore.QSize(200,200))

         self.menubar = QtGui.QMenuBar(self)
         self.setMenuBar(self.menubar)

         self.menuFile = QtGui.QMenu(self.menubar)
         self.menuFile.setTitle("&File")

         self.actionExit = QtGui.QAction(self)
         self.actionExit.setText("E&xit")
         self.connect(self.actionExit,
                  QtCore.SIGNAL("activated()"),
                  self.close)
         self.menuFile.addAction(self.actionExit)
         self.menubar.addAction(self.menuFile.menuAction())

         p = QtGui.QPalette()
         brush = QtGui.QBrush(QtCore.Qt.white,QtGui.QPixmap('x.jpg'))
         p.setBrush(QtGui.QPalette.Active,QtGui.QPalette.Window,brush)
         p.setBrush(QtGui.QPalette.Inactive,QtGui.QPalette.Window,brush)
         p.setBrush(QtGui.QPalette.Disabled,QtGui.QPalette.Window,brush)
         self.setPalette(p)

         self.show()

def main(args):
     app = QtGui.QApplication(args)
     mainWindow = MainWindow()
     sys.exit(app.exec_())

if __name__ == '__main__':
     main(sys.argv)

------------------------end code--------------------------------------
-- 
Yuma Educational Computer Consortium
Compass Development Team
Kerri Reno
kreno at yumaed.org      (928) 502-4240



-------------- next part --------------
A non-text attachment was scrubbed...
Name: x.jpg
Type: image/jpeg
Size: 1110 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20070321/9c564e21/x.jpg


More information about the PyQt mailing list