KDE 4.7 PyKDE API Reference

- KDE's Python API

# KDateTimeEdit Class Reference

`from PyKDE4.kdeui import *`

Inherits: QWidget → QObject

## Detailed Description

## Enumerations
Option | { ShowCalendar, ShowDate, ShowTime, ShowTimeSpec, EditDate, EditTime, SelectCalendar, SelectDate, SelectTime, SelectTimeSpec, DatePicker, DateKeywords, ForceTime, WarnOnInvalid }
## Signals
| calendarChanged (KLocale.CalendarSystem calendarSystem)
| calendarEntered (KLocale.CalendarSystem calendarSystem)
| dateChanged (QDate date)
| dateEdited (QDate date)
| dateEntered (QDate date)
| dateTimeChanged (KDateTime dateTime)
| dateTimeEdited (KDateTime dateTime)
| dateTimeEntered (KDateTime dateTime)
| timeChanged (QTime time)
| timeEdited (QTime time)
| timeEntered (QTime time)
| timeSpecChanged (KDateTime.Spec spec)
| timeSpecEntered (KDateTime.Spec spec)
## Methods
| __init__ (self, QWidget parent=0)
| assignCalendarSystem (self, KLocale.CalendarSystem calendarSystem)
| assignDate (self, QDate date)
| assignDateTime (self, KDateTime dateTime)
| assignTime (self, QTime time)
KLocale.CalendarSystem | calendarSystem (self)
[KLocale.CalendarSystem] | calendarSystemsList (self)
QDate | date (self)
KLocale.DateFormat | dateDisplayFormat (self)
KLocale.DateFormat | dateDisplayFormat (self)
{QDate:QString} | dateMap (self)
KDateTime | dateTime (self)
bool | eventFilter (self, QObject object, QEvent event)
| focusInEvent (self, QFocusEvent event)
| focusOutEvent (self, QFocusEvent event)
bool | isNull (self)
bool | isNullDate (self)
bool | isNullTime (self)
bool | isValid (self)
bool | isValidDate (self)
bool | isValidTime (self)
KDateTime | maximumDateTime (self)
KDateTime | minimumDateTime (self)
KDateTimeEdit.Options | options (self)
| resetDateTimeRange (self)
| resetMaximumDateTime (self)
| resetMinimumDateTime (self)
| resizeEvent (self, QResizeEvent event)
| setCalendar (self, KCalendarSystem calendar=0)
| setCalendarSystem (self, KLocale.CalendarSystem calendarSystem)
| setCalendarSystemsList (self, [KLocale.CalendarSystem] calendars)
| setDate (self, QDate date)
| setDateDisplayFormat (self, KLocale.DateFormat format)
| setDateMap (self, {QDate:QString} dateMap)
| setDateTime (self, KDateTime dateTime)
| setDateTimeRange (self, KDateTime minDateTime, KDateTime maxDateTime, QString minWarnMsg=QString(), QString maxWarnMsg=QString())
| setMaximumDateTime (self, KDateTime maxDateTime, QString maxWarnMsg=QString())
| setMinimumDateTime (self, KDateTime minDateTime, QString minWarnMsg=QString())
| setOptions (self, KDateTimeEdit.Options options)
| setTime (self, QTime time)
| setTimeDisplayFormat (self, KLocale.TimeFormatOptions formatOptions)
| setTimeList (self, [QTime] timeList, QString minWarnMsg=QString(), QString maxWarnMsg=QString())
| setTimeListInterval (self, int minutes)
| setTimeSpec (self, KDateTime.Spec spec)
| setTimeZones (self, {QString:KTimeZone} zones)
QTime | time (self)
KLocale.TimeFormatOptions | timeDisplayFormat (self)
KLocale.TimeFormatOptions | timeDisplayFormat (self)
[QTime] | timeList (self)
int | timeListInterval (self)
KDateTime.Spec | timeSpec (self)
{QString:KTimeZone} | timeZones (self)

## Signal Documentation

calendarChanged | ( | KLocale.CalendarSystem | calendarSystem
| ) |  |  |

Signal if the Calendar System has been changed either manually by the user or programatically.

Parameters:

  | calendarSystem | the new calendar system

Signal syntax:
  `QObject.connect(source, SIGNAL("calendarChanged(KLocale::CalendarSystem)"), target_slot)`

calendarEntered | ( | KLocale.CalendarSystem | calendarSystem
| ) |  |  |

Signal if the Calendar System has been manually entered by the user.

Parameters:

  | calendarSystem | the new calendar system

Signal syntax:
  `QObject.connect(source, SIGNAL("calendarEntered(KLocale::CalendarSystem)"), target_slot)`

dateChanged | ( | QDate | date
| ) |  |  |

Signal if the date has been changed either manually by the user or programatically.

The returned date may be invalid.

Parameters:

  | date | the new date

Signal syntax:
  `QObject.connect(source, SIGNAL("dateChanged(const QDate&)"), target_slot)`

dateEdited | ( | QDate | date
| ) |  |  |

Signal if the date is being manually edited by the user.

The returned date may be invalid.

Parameters:

  | date | the new date

Signal syntax:
  `QObject.connect(source, SIGNAL("dateEdited(const QDate&)"), target_slot)`

dateEntered | ( | QDate | date
| ) |  |  |

Signal if the date has been manually entered by the user.

The returned date may be invalid.

Parameters:

  | date | the new date

Signal syntax:
  `QObject.connect(source, SIGNAL("dateEntered(const QDate&)"), target_slot)`

dateTimeChanged | ( | KDateTime | dateTime
| ) |  |  |

Signal if the date or time has been changed either manually by the user or programatically.

The returned date and time may be invalid.

Parameters:

  | dateTime | the new date, time and time spec

Signal syntax:
  `QObject.connect(source, SIGNAL("dateTimeChanged(const KDateTime&)"), target_slot)`

dateTimeEdited | ( | KDateTime | dateTime
| ) |  |  |

Signal if the date or time is being manually edited by the user.

The returned date and time may be invalid.

Parameters:

  | dateTime | the new date, time and time spec

Signal syntax:
  `QObject.connect(source, SIGNAL("dateTimeEdited(const KDateTime&)"), target_slot)`

dateTimeEntered | ( | KDateTime | dateTime
| ) |  |  |

Signal if the date or time has been manually entered by the user.

The returned date and time may be invalid.

Parameters:

  | dateTime | the new date, time and time spec

Signal syntax:
  `QObject.connect(source, SIGNAL("dateTimeEntered(const KDateTime&)"), target_slot)`

timeChanged | ( | QTime | time
| ) |  |  |

Signal if the time has been changed either manually by the user or programatically.

The returned time may be invalid.

Parameters:

  | time | the new time

Signal syntax:
  `QObject.connect(source, SIGNAL("timeChanged(const QTime&)"), target_slot)`

timeEdited | ( | QTime | time
| ) |  |  |

Signal if the time is being manually edited by the user.

The returned time may be invalid.

Parameters:

  | time | the new time

Signal syntax:
  `QObject.connect(source, SIGNAL("timeEdited(const QTime&)"), target_slot)`

timeEntered | ( | QTime | time
| ) |  |  |

Signal if the time has been manually entered by the user.

The returned time may be invalid.

Parameters:

  | time | the new time

Signal syntax:
  `QObject.connect(source, SIGNAL("timeEntered(const QTime&)"), target_slot)`

timeSpecChanged | ( | KDateTime.Spec | spec
| ) |  |  |

Signal if the time spec has been changed either manually by the user or programatically.

Parameters:

  | timeSpec | the new time spec

Signal syntax:
  `QObject.connect(source, SIGNAL("timeSpecChanged(const KDateTime::Spec&)"), target_slot)`

timeSpecEntered | ( | KDateTime.Spec | spec
| ) |  |  |

Signal if the time spec has been changed manually by the user.

Parameters:

  | timeSpec | the new time spec

Signal syntax:
  `QObject.connect(source, SIGNAL("timeSpecEntered(const KDateTime::Spec&)"), target_slot)`

## Method Documentation

__init__ | ( | self, |
|  | QWidget | parent=0
| ) |  |  |

Create a new KDateTimeEdit widget

assignCalendarSystem | ( | self, |
|  | KLocale.CalendarSystem | calendarSystem
| ) |  |  |

Assign the calendar system for the widget.

Virtual to allow sub-classes to apply extra validation rules, but reimplementations must call the parent method at the end.

Parameters:

  | calendarSystem | the new calendar system

assignDate | ( | self, |
|  | QDate | date
| ) |  |  |

Assign the date for the widget.

Virtual to allow sub-classes to apply extra validation rules, but reimplementations must call the parent method at the end.

Parameters:

  | date | the new date

assignDateTime | ( | self, |
|  | KDateTime | dateTime
| ) |  |  |

Assign the date, time and time spec for the widget.

Virtual to allow sub-classes to apply extra validation rules, but reimplementations must call the parent method at the end.

Parameters:

  | datetime | the new date and time

assignTime | ( | self, |
|  | QTime | time
| ) |  |  |

Assign the time for the widget.

Virtual to allow sub-classes to apply extra validation rules, but reimplementations must call the parent method at the end.

Parameters:

  | time | the new time

KLocale.CalendarSystem calendarSystem | ( |  | self ) |

Returns the Calendar System type used by the widget

See also:
  KLocale.CalendarSystem

See also:
  setCalendarSystem()

Returns:
  the Calendar System currently used

[KLocale.CalendarSystem] calendarSystemsList | ( |  | self ) |

Returns the list of Calendar Systems displayed.

Parameters:

  | calendars | the list of calendar systems to display

QDate date | ( |  | self ) |

Return the currently selected date

Returns:
  the currently selected date

KLocale.DateFormat dateDisplayFormat | ( |  | self ) |

Return the currently set date display format

By default this is the Short Date

Returns:
  the currently set date format

KLocale.DateFormat dateDisplayFormat | ( |  | self ) |

Return the currently set date display format

By default this is the Short Date

Returns:
  the currently set date format

{QDate:QString} dateMap | ( |  | self ) |

Return the map of dates listed in the drop-down and their displayed string forms.

See also:
  setDateMap()

Returns:
  the select date map

KDateTime dateTime | ( |  | self ) |

Return the currently selected date, time and time spec

Returns:
  the currently selected date, time and time spec

bool eventFilter | ( | self, |
|  | QObject | object,
|  | QEvent | event
| ) |  |  |

focusInEvent | ( | self, |
|  | QFocusEvent | event
| ) |  |  |

focusOutEvent | ( | self, |
|  | QFocusEvent | event
| ) |  |  |

bool isNull | ( |  | self ) |

Return if the current user input is null

See also:
  isValid()

Returns:
  if the current user input is null

bool isNullDate | ( |  | self ) |

Return if the current user input date is null

See also:
  isValidDate()

Returns:
  if the current user input date is null

bool isNullTime | ( |  | self ) |

Return if the current user input time is null

See also:
  isValidTime()

Returns:
  if the current user input time is null

bool isValid | ( |  | self ) |

Return if the current user input is valid

If the user input is null then it is not valid

See also:
  isNull()

Returns:
  if the current user input is valid

bool isValidDate | ( |  | self ) |

Return if the current user input date is valid

If the user input date is null then it is not valid

See also:
  isNullDate()

Returns:
  if the current user input date is valid

bool isValidTime | ( |  | self ) |

Return if the current user input time is valid

If the user input time is null then it is not valid

See also:
  isNullTime()

Returns:
  if the current user input time is valid

KDateTime maximumDateTime | ( |  | self ) |

Return the current maximum date and time

Returns:
  the current maximum date and time

KDateTime minimumDateTime | ( |  | self ) |

Return the current minimum date and time

Returns:
  the current minimum date and time

KDateTimeEdit.Options options | ( |  | self ) |

Return the currently set widget options

Returns:
  the currently set widget options

resetDateTimeRange | ( |  | self ) |

Reset the minimum and maximum date and time to the default

resetMaximumDateTime | ( |  | self ) |

Reset the minimum date and time to the default

resetMinimumDateTime | ( |  | self ) |

Reset the minimum date and time to the default

resizeEvent | ( | self, |
|  | QResizeEvent | event
| ) |  |  |

setCalendar | ( | self, |
|  | KCalendarSystem | calendar=0
| ) |  |  |

Changes the calendar system to use. Can use its own local locale if set.

You retain ownership of the calendar object, it will not be destroyed with the widget.

Parameters:

  | calendar | the calendar system object to use, defaults to global

setCalendarSystem | ( | self, |
|  | KLocale.CalendarSystem | calendarSystem
| ) |  |  |

Set the Calendar System used for this widget. Uses the global locale.

See also:
  KLocale.CalendarSystem

See also:
  calendarSystem()

Parameters:

  | calendarSystem | the Calendar System to use

setCalendarSystemsList | ( | self, |
|  | [KLocale.CalendarSystem] | calendars
| ) |  |  |

Set the list of Calendar Systems to display.

Parameters:

  | calendars | the list of calendar systems to display

setDate | ( | self, |
|  | QDate | date
| ) |  |  |

Set the currently selected date

Parameters:

  | date | the new date

setDateDisplayFormat | ( | self, |
|  | KLocale.DateFormat | format
| ) |  |  |

Sets the date format to display.

By default is the Short Date format.

Parameters:

  | format | the date format to use

setDateMap | ( | self, |
|  | {QDate:QString} | dateMap
| ) |  |  |

Set the list of dates able to be selected from the drop-down and the string form to display for those dates, e.g. "2010-01-01" and "Yesterday".

Any invalid or duplicate dates will be used, the list will NOT be sorted, and the minimum and maximum date will not be affected.

The dateMap is keyed by the date to be listed and the value is the string to be displayed. If you want the date to be displayed in the default date format then the string should be null. If you want a separator to be displayed then set the string to "seperator".

See also:
  dateMap()

Parameters:

  | dateMap | the map of dates able to be selected

setDateTime | ( | self, |
|  | KDateTime | dateTime
| ) |  |  |

Set the currently selected date, time and time spec

Parameters:

  | dateTime | the new date, time and time spec

setDateTimeRange | ( | self, |
|  | KDateTime | minDateTime,
|  | KDateTime | maxDateTime,
|  | QString | minWarnMsg=QString(),
|  | QString | maxWarnMsg=QString()
| ) |  |  |

Set the minimum and maximum date and time range

To enable range checking provide two valid dates. To disable range checking provide two invalid dates, or call clearDateRange;

Parameters:

  | minDateTime | the minimum date and time
  | maxDateTime | the maximum date and time
  | minWarnMsg | the minimum warning message
  | maxWarnMsg | the maximum warning message

setMaximumDateTime | ( | self, |
|  | KDateTime | maxDateTime,
|  | QString | maxWarnMsg=QString()
| ) |  |  |

Set the maximum allowed date.

If the date is invalid, or less than current minimum, then the maximum will not be set.

See also:
  setMinimumDateTime()

See also:
  setDateRange()

Parameters:

  | maxDate | the maximum date
  | maxWarnMsg | the maximum warning message

setMinimumDateTime | ( | self, |
|  | KDateTime | minDateTime,
|  | QString | minWarnMsg=QString()
| ) |  |  |

Set the minimum allowed date.

If the date is invalid, or more than current maximum, then the minimum will not be set.

See also:
  setMaximumDateTime()

See also:
  setDateRange()

Parameters:

  | maxDate | the minimum date
  | maxWarnMsg | the minimum warning message

setOptions | ( | self, |
|  | KDateTimeEdit.Options | options
| ) |  |  |

Set the new widget options

Parameters:

  | options | the new widget options

setTime | ( | self, |
|  | QTime | time
| ) |  |  |

Set the currently selected time

Parameters:

  | time | the new time

setTimeDisplayFormat | ( | self, |
|  | KLocale.TimeFormatOptions | formatOptions
| ) |  |  |

Sets the time format to display.

By default is the Short Time format.

Parameters:

  | format | the time format to use

setTimeList | ( | self, |
|  | [QTime] | timeList,
|  | QString | minWarnMsg=QString(),
|  | QString | maxWarnMsg=QString()
| ) |  |  |

Set the list of times able to be selected from the drop-down.

Setting the time list will override any time interval previously set via setTimeListInterval().

Any invalid or duplicate times will be ignored, and the list will be sorted.

The minimum and maximum time will automatically be set to the earliest and latest value in the list.

See also:
  timeList()

Parameters:

  | timeList | the list of times able to be selected
  | minWarnMsg | the minimum warning message
  | maxWarnMsg | the maximum warning message

setTimeListInterval | ( | self, |
|  | int | minutes
| ) |  |  |

Set the interval between times able to be selected from the drop-down.

The combo drop-down will be populated with times every

Parameters:

  | minutes | apart, starting from the minimumTime() and ending at maximumTime().

If the ForceInterval option is set then any time manually typed into the combo line edit will be forced to the nearest interval.

This interval must be an exact divisor of the valid time range hours. For example with the default 24 hour range interval must divide 1440 minutes exactly, meaning 1, 6 and 90 are valid but 7, 31 and 91 are not.

Setting the time list interval will override any time list previously set via setTimeList().

See also:
  timeListInterval()

Parameters:

  | minutes | the time list interval to display

setTimeSpec | ( | self, |
|  | KDateTime.Spec | spec
| ) |  |  |

Set the current time spec

Parameters:

  | spec | the new spec

setTimeZones | ( | self, |
|  | {QString:KTimeZone} | zones
| ) |  |  |

Set the time zones able to be selected

Parameters:

  | zones | the time zones to display

QTime time | ( |  | self ) |

Return the currently selected time

Returns:
  the currently selected time

KLocale.TimeFormatOptions timeDisplayFormat | ( |  | self ) |

Return the currently set time format

By default this is the Short Time

Returns:
  the currently set time format

KLocale.TimeFormatOptions timeDisplayFormat | ( |  | self ) |

Return the currently set time format

By default this is the Short Time

Returns:
  the currently set time format

[QTime] timeList | ( |  | self ) |

Return the list of times able to be selected in the drop-down.

See also:
  setTimeList()

See also:
  timeListInterval()

See also:
  setTimeListInterval()

Returns:
  the select time list

int timeListInterval | ( |  | self ) |

Return the time list interval able to be selected

Returns:
  the select time intervals in minutes

KDateTime.Spec timeSpec | ( |  | self ) |

Return the currently selected time spec

Returns:
  the currently selected time spec

{QString:KTimeZone} timeZones | ( |  | self ) |

Return the list of time zones able to be selected

Parameters:

  | zones | the time zones to display

## Enumeration Documentation

Option

Options provided by the widget

See also:
  options

See also:
  setOptions

Enumerator:

  EditTime = 0x0001 |
  SelectTime = 0x0002 |
  ForceTime = 0x0004 |
  WarnOnInvalid = 0x0008 |