Last active
May 20, 2018 02:26
-
-
Save eyllanesc/2830d916daf329f9d28af92fa3aeda0e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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