Skip to content

Instantly share code, notes, and snippets.

@eyllanesc
Last active May 20, 2018 02:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eyllanesc/2830d916daf329f9d28af92fa3aeda0e to your computer and use it in GitHub Desktop.
Save eyllanesc/2830d916daf329f9d28af92fa3aeda0e to your computer and use it in GitHub Desktop.
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
class Manager:
def __init__(self):
self.center()
def center(self):
self.setGeometry(QStyle.alignedRect(
Qt.LeftToRight,
Qt.AlignCenter,
self.size(),
QApplication.desktop().availableGeometry()
)
)
def setBackgroundColor(self, color):
pal = self.palette()
pal.setColor(QPalette.Background, color)
self.setPalette(pal)
class MainWindow(QMainWindow, Manager):
def __init__(self):
QMainWindow.__init__(self)
Manager.__init__(self)
self.setBackgroundColor(QColor("pink"))
if __name__ == '__main__':
import sys
app = QApplication(sys.argv)
w = MainWindow()
w.show()
sys.exit(app.exec_())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment