Python Forum
pyQt5 QCalendarWidget setHeaderTextFormat
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pyQt5 QCalendarWidget setHeaderTextFormat
#1
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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Huge code problems (buttons(PyQt5),PyQt5 Threads, Windows etc) ZenWoR 0 3,499 Apr-06-2019, 11:15 PM
Last Post: ZenWoR

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020