Python PyQt5.QtCore 模块,QDate() 实例源码

我们从Python开源项目中,提取了以下14个代码示例,用于说明如何使用PyQt5.QtCore.QDate()

项目:FuME    作者:fupadev    | 项目源码 | 文件源码
def set_timeEditNow(self):
        now = datetime.datetime.now()
        self.dateEdit_3.setDate(QtCore.QDate(now.year, now.month, now.day))
        self.dateEdit_4.setDate(QtCore.QDate(now.year, now.month, now.day))
项目:FuME    作者:fupadev    | 项目源码 | 文件源码
def read_settings(self):
        self.settings = QtCore.QSettings('fume', 'Match-Explorer')

        self.resize(self.settings.value('mainwindow/size', self.size()))
        try:
            self.move(self.settings.value('mainwindow/pos'))
        except:
            pass

        self.actionZeitraum.setChecked(self.settings.value('menubar/date/range', True, bool))
        self.actionZeitpunkt.setChecked(self.settings.value('menubar/date/day', False, bool))

        now = datetime.datetime.now()
        self.dateEdit_3.setDate(self.settings.value('date_from_calendar', QtCore.QDate(now.year, now.month, now.day)))
        self.dateEdit_4.setDate(self.settings.value('date_to_calendar', QtCore.QDate(now.year, now.month, now.day)))

        # dbPaths
        # Windows: ?C:\Users\<User>\AppData\Local\FuME\FuME
        # macOS: /Users/<User>/Library/Application Support/FuME
        userDataDir = appdirs.user_data_dir('FuME', 'FuME')
        src = self.get_pathToTemp(['db', 'sql_default.db'])
        dst = os.path.join(userDataDir, 'sql.db')
        if not os.path.exists(userDataDir):
            os.makedirs(userDataDir)
            shutil.copy(src, dst)
        self.dbPath = dst
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def reformatCalendarPage(self):
        if self.firstFridayCheckBox.isChecked():
            firstFriday = QDate(self.calendar.yearShown(),
                    self.calendar.monthShown(), 1)

            while firstFriday.dayOfWeek() != Qt.Friday:
                firstFriday = firstFriday.addDays(1)

            firstFridayFormat = QTextCharFormat()
            firstFridayFormat.setForeground(Qt.blue)

            self.calendar.setDateTextFormat(firstFriday, firstFridayFormat)

        # May 1st in Red takes precedence.
        if self.mayFirstCheckBox.isChecked():
            mayFirst = QDate(self.calendar.yearShown(), 5, 1)

            mayFirstFormat = QTextCharFormat()
            mayFirstFormat.setForeground(Qt.red)

            self.calendar.setDateTextFormat(mayFirst, mayFirstFormat)
项目:examples    作者:pyqt    | 项目源码 | 文件源码
def reformatCalendarPage(self):
        if self.firstFridayCheckBox.isChecked():
            firstFriday = QDate(self.calendar.yearShown(),
                    self.calendar.monthShown(), 1)

            while firstFriday.dayOfWeek() != Qt.Friday:
                firstFriday = firstFriday.addDays(1)

            firstFridayFormat = QTextCharFormat()
            firstFridayFormat.setForeground(Qt.blue)

            self.calendar.setDateTextFormat(firstFriday, firstFridayFormat)

        # May 1st in Red takes precedence.
        if self.mayFirstCheckBox.isChecked():
            mayFirst = QDate(self.calendar.yearShown(), 5, 1)

            mayFirstFormat = QTextCharFormat()
            mayFirstFormat.setForeground(Qt.red)

            self.calendar.setDateTextFormat(mayFirst, mayFirstFormat)
项目:pyqt5-example    作者:guinslym    | 项目源码 | 文件源码
def reformatCalendarPage(self):
        if self.firstFridayCheckBox.isChecked():
            firstFriday = QDate(self.calendar.yearShown(),
                    self.calendar.monthShown(), 1)

            while firstFriday.dayOfWeek() != Qt.Friday:
                firstFriday = firstFriday.addDays(1)

            firstFridayFormat = QTextCharFormat()
            firstFridayFormat.setForeground(Qt.blue)

            self.calendar.setDateTextFormat(firstFriday, firstFridayFormat)

        # May 1st in Red takes precedence.
        if self.mayFirstCheckBox.isChecked():
            mayFirst = QDate(self.calendar.yearShown(), 5, 1)

            mayFirstFormat = QTextCharFormat()
            mayFirstFormat.setForeground(Qt.red)

            self.calendar.setDateTextFormat(mayFirst, mayFirstFormat)
项目:DGP    作者:DynamicGravitySystems    | 项目源码 | 文件源码
def accept(self):
        # TODO: Change test meter to actual meter
        qdate = self.date_flight.date()  # type: QtCore.QDate
        date = datetime.date(qdate.year(), qdate.month(), qdate.day())
        self._flight = prj.Flight(self._project, self.text_name.text(), self._project.get_meter(
            self.combo_meter.currentText()), uuid=self._uid, date=date)
        super().accept()
项目:climate    作者:FIDS-UWO    | 项目源码 | 文件源码
def idw_reset_input(self):
        self.files = []
        self.stations = {}
        self.ui.pathLineEdit.setText("")
        self.ui.outputLineEdit.setText("")
        self.ui.varEdit.setText("")
        self.ui.alphaSpin.setValue(2)
        self.ui.pointsSpin.setValue(4)
        self.ui.extraLineEdit.setText("")
        self.ui.startDateEdit.setDate(QtCore.QDate(1975, 1, 1))
        self.ui.endDateEdit.setDate(QtCore.QDate(2005, 1, 1))
        self.ui.northSpin.setValue(0)
        self.ui.eastSpin.setValue(0)
        self.ui.southSpin.setValue(0)
        self.ui.westSpin.setValue(0)
        self.ui.timeGroupBox.setChecked(False)
        self.ui.spatialGroupBox.setChecked(False)

        R = self.ui.stationTable.rowCount()
        C = self.ui.stationTable.columnCount()

        for r in range(R):
            for c in range(C):
                cell = self.ui.stationTable.item(r, c)
                if cell:
                    cell.setText("")
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def createPreviewGroupBox(self):
        self.previewGroupBox = QGroupBox("Preview")

        self.calendar = QCalendarWidget()
        self.calendar.setMinimumDate(QDate(1900, 1, 1))
        self.calendar.setMaximumDate(QDate(3000, 1, 1))
        self.calendar.setGridVisible(True)
        self.calendar.currentPageChanged.connect(self.reformatCalendarPage)

        self.previewLayout = QGridLayout()
        self.previewLayout.addWidget(self.calendar, 0, 0, Qt.AlignCenter)
        self.previewGroupBox.setLayout(self.previewLayout)
项目:examples    作者:pyqt    | 项目源码 | 文件源码
def createPreviewGroupBox(self):
        self.previewGroupBox = QGroupBox("Preview")

        self.calendar = QCalendarWidget()
        self.calendar.setMinimumDate(QDate(1900, 1, 1))
        self.calendar.setMaximumDate(QDate(3000, 1, 1))
        self.calendar.setGridVisible(True)
        self.calendar.currentPageChanged.connect(self.reformatCalendarPage)

        self.previewLayout = QGridLayout()
        self.previewLayout.addWidget(self.calendar, 0, 0, Qt.AlignCenter)
        self.previewGroupBox.setLayout(self.previewLayout)
项目:well-being-diary    作者:SunyataZero    | 项目源码 | 文件源码
def update_gui(self):
        self.calendar_widget.setDateTextFormat(QtCore.QDate(), QtGui.QTextCharFormat())
        # -using the "null date" to clear

        date_qtextcharformat = QtGui.QTextCharFormat()
        date_qtextcharformat.setFontWeight(QtGui.QFont.Bold)
        for diarym in wbd.model.DiaryEntryM.get_all():
            qdatetime = QtCore.QDateTime.fromMSecsSinceEpoch(diarym.date_added_it * 1000)
            self.calendar_widget.setDateTextFormat(qdatetime.date(), date_qtextcharformat)
项目:well-being-diary    作者:SunyataZero    | 项目源码 | 文件源码
def on_today_button_clicked(self):
        self.calendar_widget.setSelectedDate(QtCore.QDate.currentDate())
        """
        if wbd.bwbglobal.active_view_viewenum == wbd.bwbglobal.ViewEnum.diary_daily_overview:
            self.calendar_widget.setSelectedDate(QtCore.QDate.currentDate())
        else:
            self.calendar_widget.showToday()
        """
        self.update_gui()

        # TODO: We may also want to switch to daily overview, alternatively we could
        # 1. change the button when we're in the monthly view or
        # 2. display two buttons, which both changes the view as well as the day/month selected
        # Please note though that there is a difference between the month and day views in that
        # month views are not selecting a month, only viewing
项目:well-being-diary    作者:SunyataZero    | 项目源码 | 文件源码
def qdate_to_unixtime(i_qdate: QtCore.QDate) -> int:
    qdatetime = QtCore.QDateTime(i_qdate)
    unixtime_it = qdatetime.toMSecsSinceEpoch() // 1000
    return unixtime_it
项目:pyqt5-example    作者:guinslym    | 项目源码 | 文件源码
def createPreviewGroupBox(self):
        self.previewGroupBox = QGroupBox("Preview")

        self.calendar = QCalendarWidget()
        self.calendar.setMinimumDate(QDate(1900, 1, 1))
        self.calendar.setMaximumDate(QDate(3000, 1, 1))
        self.calendar.setGridVisible(True)
        self.calendar.currentPageChanged.connect(self.reformatCalendarPage)

        self.previewLayout = QGridLayout()
        self.previewLayout.addWidget(self.calendar, 0, 0, Qt.AlignCenter)
        self.previewGroupBox.setLayout(self.previewLayout)
项目:DCheat    作者:DCheat    | 项目源码 | 文件源码
def __init__(self, socket, name, testDate, startTime, endTime, banList, allowList, parent=None):
        QtWidgets.QDialog.__init__(self, parent)
        self.ui = uic.loadUi(config.config.ROOT_PATH +'view/updateCourse.ui', self)
        self.sock = socket

        self.name = name
        self.date = testDate.split('-')
        self.startTime = startTime.split(':')
        self.endTime = endTime.split(':')
        self.banList = banList
        self.allowList = allowList

        self.students = []
        self.ui.label_5.setText(self.name)


        self.ui.dateEdit.setDate(QDate(int(self.date[0]), int(self.date[1]), int(self.date[2])))
        self.ui.timeEdit.setTime(QTime(int(self.startTime[0]), int(self.startTime[1])))
        self.ui.timeEdit_2.setTime(QTime(int(self.endTime[0]), int(self.endTime[1])))

        pListWidget = QtWidgets.QWidget()
        self.ui.scrollArea.setWidgetResizable(True)
        self.ui.scrollArea.setWidget(pListWidget)
        pListLayout = QtWidgets.QVBoxLayout()
        pListLayout.setAlignment(Qt.AlignTop)
        pListWidget.setLayout(pListLayout)

        for i in range(1, len(config.config.BAN_PROGRAM)):
            checkBox = QtWidgets.QCheckBox(config.config.BAN_PROGRAM[i])
            checkBox.clicked.connect(self.set_ban_list)

            if i in self.banList:
                checkBox.setChecked(True)

            pListLayout.addWidget(checkBox)


        sListWidget = QtWidgets.QWidget()
        self.ui.scrollArea_2.setWidgetResizable(True)
        self.ui.scrollArea_2.setWidget(sListWidget)
        sListLayout = QtWidgets.QVBoxLayout()
        sListLayout.setAlignment(Qt.AlignTop)
        sListWidget.setLayout(sListLayout)

        for i in range(1, len(config.config.ALLOW_SITE)):
            checkBox = QtWidgets.QCheckBox(config.config.ALLOW_SITE[i])
            checkBox.clicked.connect(self.set_allow_list)

            if i in self.allowList:
                checkBox.setChecked(True)

            sListLayout.addWidget(checkBox)

        self.ui.show()