Python Forum

Full Version: pyQt5 QCalendarWidget setHeaderTextFormat
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
As written displays widget with a black background (what I want) except for the outer frame and the horizontal header. want to make the entire widget with black background. I cannot get the syntax right. Any suggestions? Thank you.

from PyQt5.QtWidgets import QApplication, QPushButton, QWidget, QDialog, QVBoxLayout, QCalendarWidget, QLabel
import sys
from PyQt5 import QtGui
from PyQt5.QtCore import Qt, pyqtSlot
from PyQt5.QtGui import QTextCharFormat, QBrush, QColor, QTextFormat

class Window(QDialog):

   def __init__(self):
        super().__init__()
        self.left = 700
        self.top = 500
        self.width = 100
        self.height = 75
        self.setGeometry(self.left, self.top, self.width, self.height)
        self.setWindowFlags(Qt.FramelessWindowHint)
        self.Calendar()

        self.show()

   def Calendar(self):
       vbox =  QVBoxLayout()
       format = QTextCharFormat()
       self.calendar = QCalendarWidget()
       self.calendar.setHorizontalHeaderFormat(QCalendarWidget.SingleLetterDayNames)
       self.calendar.setVerticalHeaderFormat(QCalendarWidget.NoVerticalHeader)
#       self.calendar.setHeaderTextFormat(format.setBackground(Qt.black))
       self.calendar.setSelectionMode(QCalendarWidget.NoSelection)
       self.calendar.setStyleSheet("background-color: black; color: rgba(162, 201, 229, 255); ")
       vbox.addWidget(self.calendar)
       self.setLayout(vbox)

if __name__ == '__main__':
    app = QApplication(sys.argv)
    window = Window()
    sys.exit(app.exec_())
İmage