當前位置: 首頁>>代碼示例>>Python>>正文


Python QtWidgets.QCalendarWidget方法代碼示例

本文整理匯總了Python中PyQt5.QtWidgets.QCalendarWidget方法的典型用法代碼示例。如果您正苦於以下問題:Python QtWidgets.QCalendarWidget方法的具體用法?Python QtWidgets.QCalendarWidget怎麽用?Python QtWidgets.QCalendarWidget使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt5.QtWidgets的用法示例。


在下文中一共展示了QtWidgets.QCalendarWidget方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QCalendarWidget [as 別名]
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_() 
開發者ID:aroberge,項目名稱:easygui_qt,代碼行數:27,代碼來源:calendar_widget.py

示例2: setupUi

# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QCalendarWidget [as 別名]
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) 
開發者ID:PacktPublishing,項目名稱:Qt5-Python-GUI-Programming-Cookbook,代碼行數:14,代碼來源:demoCalendar.py

示例3: setupUi

# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QCalendarWidget [as 別名]
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) 
開發者ID:PacktPublishing,項目名稱:Mastering-GUI-Programming-with-Python,代碼行數:60,代碼來源:calendar_form.py


注:本文中的PyQt5.QtWidgets.QCalendarWidget方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。