Skip to content

Pass the date value to the DateItem display callback - #128

Merged
PierreRaybaut merged 1 commit into
masterfrom
fix/126-dateitem-callback-value
Oct 30, 2026
Merged

PierreRaybaut merged 1 commit into
masterfrom
fix/126-dateitem-callback-value

Conversation

@PierreRaybaut

Copy link
Copy Markdown
Collaborator

Closes #126.

Problem

DateWidget.date_changed() forwarded the raw argument of the dateTimeChanged signal to the display callback of a DateItem. The callback therefore received a QDateTime object instead of the value of the item, and its type depends on the Qt binding (PyQt5, PyQt6 or PySide6).

Since #127, the callback of DateTimeItem receives a datetime.datetime, so DateItem was the only date item still receiving a Qt object.

Fix

DateWidget.date_changed() now passes the Python value of the widget (self.value(), a datetime.date) to the callback, exactly like DateTimeWidget and the other widgets.

Behavior change: callbacks relying on the previous QDateTime argument must be updated. The release notes mention it. No DateItem with a display callback was found in PlotPy, Sigima, DataLab, DataLab-Web or the DataLab plugins. Callbacks reading the value from the dataset instance are not affected, because the dataset is updated before the callback is called. Shipping this in 3.17.0, a minor release, keeps the date items consistent in this version.

Tests

  • New test_date_display_callback in guidata/tests/unit/test_datetime_display_callback.py: changing the date calls the callback once with a datetime.date, and the dataset is already updated. Without the fix, it fails because the callback receives a QDateTime.

Local validation (Windows):

Binding Python Result
PyQt5 5.15 3.11 263 passed, 2 skipped
PyQt6 6.10 3.14 261 passed, 4 skipped
PySide6 6.10 3.14 261 passed, 4 skipped
  • ruff check / ruff format --check: clean.

Release notes

Entry added to doc/release_notes/release_3.17.md (bug fixes).

DateWidget forwarded the raw argument of the dateTimeChanged signal to
the display callback: a QDateTime object, whose type depends on the Qt
binding, instead of the value of the item. Pass the Python value of the
widget (datetime.date), like DateTimeWidget and the other widgets.

Callbacks relying on the previous QDateTime argument must be updated.

Refs #126

Assisted-by: Claude Opus 5.5
@PierreRaybaut
PierreRaybaut merged commit 3d9d80a into master Oct 30, 2026
9 checks passed
@PierreRaybaut
PierreRaybaut deleted the fix/126-dateitem-callback-value branch October 30, 2026 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DateItem display callback receives a QDateTime instead of a date

1 participant