= Windows with gradient backgrounds = On the #pyqt channel on Freenode, `felipe__` asked if it was possible to change the background colour of a window. This code shows how it can be done with a fixed gradient. If you are subclassing QWidget or another widget class, it may be worth reimplementing its `resizeEvent()` method to modify the gradient so that it changes when the window is resized. {{{ #!python import sys from PyQt4.QtGui import * if __name__ == "__main__": app = QApplication([]) w = QWidget() p = QPalette() gradient = QLinearGradient(0, 0, 0, 400) gradient.setColorAt(0.0, QColor(240, 240, 240)) gradient.setColorAt(1.0, QColor(240, 160, 160)) p.setBrush(QPalette.Window, QBrush(gradient)) w.setPalette(p) w.show() app.exec_() }}}