def __init__(self, title=None): super(TitleWidget, self).__init__() if sys.platform.startswith("darwin"): color1 = QColor(230, 230, 230, 255) color2 = QColor(177, 177, 177, 255) gradient = QLinearGradient() gradient.setStart(0, 0) gradient.setFinalStop(0, TitleWidget.TitleHeight) gradient.setColorAt(0, color1) gradient.setColorAt(1, color2) brush = QBrush(gradient) palette = QPalette() palette.setBrush(QPalette.Background, brush) self.setPalette(palette) self.setAutoFillBackground(True) self.setMaximumHeight(TitleWidget.TitleHeight) self.setMinimumHeight(TitleWidget.TitleHeight) self.titleLabel = QLabel("", parent=self) font = self.titleLabel.font() font.setPixelSize(11) self.titleLabel.setFont(font) self.titleLabel.setAlignment(Qt.AlignCenter) self.titleLabel.setText(title) layout = QVBoxLayout() layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.titleLabel) self.setLayout(layout)
def paintEvent(self, e): p = QPalette() print self.width(), self.height() gradient = QtGui.QRadialGradient(self.width() / 2, self.height() / 2, min(self.width(), self.height())) gradient.setColorAt(0.7, QtGui.QColor(0, 0, 0)) gradient.setColorAt(0.0, QtGui.QColor(0, 255, 0)) p.setBrush(QPalette.Window, QtGui.QBrush(gradient)) self.setPalette(p)
def initUI(self): posX, posY, sizeW, sizeH = s.GEOMETRY_MAINWIDOW self.setGeometry(posX, posY, sizeW, sizeH) self.setWindowTitle("Hospital Management System") palette = QPalette() palette.setBrush(QPalette.Background, QBrush(QPixmap(s.PATH_IMG_BG_LOGIN))) self.setPalette(palette) self.initButton() self.forDev()
def initButton(self): loader = QUiLoader() form = loader.load('RSC/loginUI/Widget_LoginUI.ui', self) self.user_id = form.findChild(QLineEdit, "lineEdit_username") self.password = form.findChild(QLineEdit, "lineEdit_password") self.login_button = form.findChild(QPushButton, "button_login") self.login_button.clicked.connect(self.logIn) palette = QPalette() palette.setBrush(QPalette.Background, QBrush(QPixmap(s.PATH_IMG_BG_LOGIN))) self.setPalette(palette)
def initUI(self): """ Initializes UI. Creates a horizontal layout to which buttons can be added. """ if self._osx: # Mimic the style of buttons underneath a list view gradient = QLinearGradient() gradient.setStart(0, 0) gradient.setFinalStop(0, self.Height) colorTop = QColor(250, 250, 250, 255) colorMid = QColor(244, 244, 244, 255) colorInBetween = QColor(238, 238, 238, 255) colorMidLow = QColor(234, 234, 234, 255) colorLow = QColor(239, 239, 239, 255) gradient.setColorAt(0, colorTop) gradient.setColorAt(0.45, colorMid) gradient.setColorAt(0.5, colorInBetween) gradient.setColorAt(0.55, colorMidLow) gradient.setColorAt(1, colorLow) brush = QBrush(gradient) palette = QPalette() palette.setBrush(QPalette.Background, brush) self.setAutoFillBackground(True) self.setPalette(palette) # Use a horizontal layout in which to keep # buttons. Initialize with an empty QWidget to # make the buttons align to the left if self.orientation == Qt.Horizontal: self.layout = QHBoxLayout() else: self.layout = QVBoxLayout() self.layout.setSpacing(0) self.layout.setContentsMargins(0, 0, 0, 0) self.layout.addWidget(QWidget()) self.setLayout(self.layout)