In this article we will see how we can get the name property of the QCalendarWidget. Name property hold the name of the calendar, name is used to distinguish the calendar with each other i.e categorize them according to the use, for example, birth calendar, booking calendar etc. By default name property contains an empty string although we can set name any time with the help of setAccessibleName method.
In order to do this we will use accessibleName method with the QCalendarWidget object. Syntax : calendar.accessibleName() Argument : It takes no argument Action Performed : It return string
Below is the implementationÂ
Python3
# importing librariesfrom PyQt5.QtWidgets import *from PyQt5 import QtCore, QtGuifrom PyQt5.QtGui import *from PyQt5.QtCore import *import sysÂ
Â
class Window(QMainWindow):Â
    def __init__(self):        super().__init__()Â
        # setting title        self.setWindowTitle("Python ")Â
        # setting geometry        self.setGeometry(100, 100, 600, 400)Â
        # calling method        self.UiComponents()Â
        # showing all the widgets        self.show()Â
    # method for components    def UiComponents(self):Â
        # creating a QCalendarWidget object        calendar = QCalendarWidget(self)Â
        # setting geometry to the calendar        calendar.setGeometry(10, 10, 400, 250)Â
        # setting name        calendar.setAccessibleName("Geek Calendar")Â
        # creating a label        label = QLabel(self)Â
        # setting geometry to the label        label.setGeometry(100, 280, 250, 60)Â
        # making label multi line        label.setWordWrap(True)Â
        # getting name        value = calendar.accessibleName()Â
        # setting text to the label        label.setText("Name: " + str(value))Â
Â
# create pyqt5 appApp = QApplication(sys.argv)Â
# create the instance of our Windowwindow = Window()Â
# start the appsys.exit(App.exec()) |
Output :

