Python PyQt5.QtWidgets.QCalendarWidget() Examples

The following are 3 code examples of PyQt5.QtWidgets.QCalendarWidget(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PyQt5.QtWidgets , or try the search function .
Example #1
Source File: calendar_widget.py    From easygui_qt with BSD 3-Clause "New" or "Revised" License 8 votes vote down vote up
def __init__(self, title="Calendar"):
        super(CalendarWidget, self).__init__()

        self.setWindowTitle(title)
        layout = qt_widgets.QGridLayout()
        layout.setColumnStretch(1, 1)

        self.cal = qt_widgets.QCalendarWidget(self)
        self.cal.setGridVisible(True)
        self.cal.clicked[QtCore.QDate].connect(self.show_date)
        layout.addWidget(self.cal, 0, 0, 1, 2)

        self.date_label = qt_widgets.QLabel()
        self.date = self.cal.selectedDate()
        self.date_label.setText(self.date.toString())
        layout.addWidget(self.date_label, 1, 0)

        button_box = qt_widgets.QDialogButtonBox()
        confirm_button = button_box.addButton(qt_widgets.QDialogButtonBox.Ok)
        confirm_button.clicked.connect(self.confirm)
        layout.addWidget(button_box, 1, 1)

        self.setLayout(layout)
        self.show()
        self.raise_() 
Example #2
Source File: demoCalendar.py    From Qt5-Python-GUI-Programming-Cookbook with MIT License 5 votes vote down vote up
def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(384, 300)
        self.calendarWidget = QtWidgets.QCalendarWidget(Dialog)
        self.calendarWidget.setGeometry(QtCore.QRect(40, 30, 312, 183))
        self.calendarWidget.setObjectName("calendarWidget")
        self.dateEdit = QtWidgets.QDateEdit(Dialog)
        self.dateEdit.setGeometry(QtCore.QRect(120, 250, 110, 22))
        self.dateEdit.setObjectName("dateEdit")

        self.retranslateUi(Dialog)
        QtCore.QMetaObject.connectSlotsByName(Dialog) 
Example #3
Source File: calendar_form.py    From Mastering-GUI-Programming-with-Python with MIT License 4 votes vote down vote up
def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(799, 600)
        self.horizontalLayout = QtWidgets.QHBoxLayout(MainWindow)
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.calendar = QtWidgets.QCalendarWidget(MainWindow)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.calendar.sizePolicy().hasHeightForWidth())
        self.calendar.setSizePolicy(sizePolicy)
        self.calendar.setObjectName("calendar")
        self.horizontalLayout.addWidget(self.calendar)
        self.verticalLayout = QtWidgets.QVBoxLayout()
        self.verticalLayout.setObjectName("verticalLayout")
        self.label = QtWidgets.QLabel(MainWindow)
        self.label.setObjectName("label")
        self.verticalLayout.addWidget(self.label)
        self.event_list = QtWidgets.QListWidget(MainWindow)
        self.event_list.setObjectName("event_list")
        self.verticalLayout.addWidget(self.event_list)
        self.groupBox = QtWidgets.QGroupBox(MainWindow)
        self.groupBox.setObjectName("groupBox")
        self.gridLayout = QtWidgets.QGridLayout(self.groupBox)
        self.gridLayout.setObjectName("gridLayout")
        self.event_category = QtWidgets.QComboBox(self.groupBox)
        self.event_category.setObjectName("event_category")
        self.event_category.addItem("")
        self.event_category.addItem("")
        self.event_category.addItem("")
        self.event_category.addItem("")
        self.event_category.addItem("")
        self.event_category.addItem("")
        self.gridLayout.addWidget(self.event_category, 1, 0, 1, 1)
        self.event_time = QtWidgets.QTimeEdit(self.groupBox)
        self.event_time.setObjectName("event_time")
        self.gridLayout.addWidget(self.event_time, 1, 1, 1, 1)
        self.event_detail = QtWidgets.QTextEdit(self.groupBox)
        self.event_detail.setObjectName("event_detail")
        self.gridLayout.addWidget(self.event_detail, 2, 0, 1, 3)
        self.event_title = QtWidgets.QLineEdit(self.groupBox)
        self.event_title.setObjectName("event_title")
        self.gridLayout.addWidget(self.event_title, 0, 0, 1, 3)
        self.allday_check = QtWidgets.QCheckBox(self.groupBox)
        self.allday_check.setObjectName("allday_check")
        self.gridLayout.addWidget(self.allday_check, 1, 2, 1, 1)
        self.add_button = QtWidgets.QPushButton(self.groupBox)
        self.add_button.setObjectName("add_button")
        self.gridLayout.addWidget(self.add_button, 3, 1, 1, 1)
        self.del_button = QtWidgets.QPushButton(self.groupBox)
        self.del_button.setObjectName("del_button")
        self.gridLayout.addWidget(self.del_button, 3, 2, 1, 1)
        self.verticalLayout.addWidget(self.groupBox)
        self.horizontalLayout.addLayout(self.verticalLayout)

        self.retranslateUi(MainWindow)
        self.allday_check.toggled['bool'].connect(self.event_time.setDisabled)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)