| 1 |
# (C) Copyright 2004-2023 Enthought, Inc., Austin, TX |
| 2 |
# All rights reserved. |
| 3 |
# |
| 4 |
# This software is provided without warranty under the terms of the BSD |
| 5 |
# license included in LICENSE.txt and may be redistributed only under |
| 6 |
# the conditions described in the aforementioned license. The license |
| 7 |
# is also available online at http://www.enthought.com/licenses/BSD.txt |
| 8 |
# |
| 9 |
# Thanks for using Enthought open source! |
| 10 |
|
| 11 |
""" |
| 12 |
Implementation of a DateRangeEditor demo plugin for Traits UI demo program. |
| 13 |
|
| 14 |
This demo shows a custom style DateRangeEditor. Note that this demo only works |
| 15 |
with qt backend. |
| 16 |
""" |
| 17 |
# Issue related to the demo warning: enthought/traitsui#962 |
| 18 |
|
| 19 |
from traits.api import HasTraits, Date, Tuple |
| 20 |
from traits.etsconfig.api import ETSConfig |
| 21 |
from traitsui.api import View, Item, DateRangeEditor, Group |
| 22 |
|
| 23 |
|
| 24 |
class DateRangeEditorDemo(HasTraits): |
| 25 |
"""Demo class to show DateRangeEditor.""" |
| 26 |
|
| 27 |
date_range = Tuple(Date, Date) |
| 28 |
|
| 29 |
traits_view = View( |
| 30 |
Group( |
| 31 |
Item( |
| 32 |
'date_range', |
| 33 |
editor=DateRangeEditor(), |
| 34 |
style='custom', |
| 35 |
label='Date range', |
| 36 |
), |
| 37 |
label='Date range', |
| 38 |
), |
| 39 |
resizable=True, |
| 40 |
) |
| 41 |
|
| 42 |
def _date_range_changed(self): |
| 43 |
print(self.date_range) |
| 44 |
|
| 45 |
|
| 46 |
# -- Set Up The Demo ------------------------------------------------------ |
| 47 |
|
| 48 |
|
| 49 |
if __name__ == "__main__": |
| 50 |
if ETSConfig.toolkit in {"qt", "qt4"}: |
| 51 |
# DateRangeEditor is currently only available for qt backend. |
| 52 |
demo = DateRangeEditorDemo() |
| 53 |
demo.configure_traits() |