def __init__(self, parent=None): QDateTimeEdit.__init__(self, parent) self.setMinimumDateTime(UNDEFINED_QDATETIME) self.setCalendarPopup(True) self.cw = CalendarWidget(self) self.cw.setVerticalHeaderFormat(QCalendarWidget.VerticalHeaderFormat.NoVerticalHeader) self.setCalendarWidget(self.cw) self.setSpecialValueText(_('Undefined'))
def keyPressEvent(self, ev): if ev.key() == Qt.Key.Key_Minus: ev.accept() self.clear_date() elif ev.key() == Qt.Key.Key_Equal: self.today_date() ev.accept() elif ev.matches(QKeySequence.StandardKey.Copy): self.copy() ev.accept() elif ev.matches(QKeySequence.StandardKey.Cut): self.cut() ev.accept() elif ev.matches(QKeySequence.StandardKey.Paste): self.paste() ev.accept() else: return QDateTimeEdit.keyPressEvent(self, ev)