| 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 |
# default_trait_editors.py -- Example of using default trait editors |
| 12 |
|
| 13 |
from traits.api import Bool, HasTraits, Range, Str |
| 14 |
from traitsui.api import Item, View |
| 15 |
|
| 16 |
|
| 17 |
class Adult(HasTraits): |
| 18 |
first_name = Str() |
| 19 |
last_name = Str() |
| 20 |
age = Range(21, 99) |
| 21 |
registered_voter = Bool() |
| 22 |
|
| 23 |
traits_view = View( |
| 24 |
Item(name='first_name'), |
| 25 |
Item(name='last_name'), |
| 26 |
Item(name='age'), |
| 27 |
Item(name='registered_voter'), |
| 28 |
) |
| 29 |
|
| 30 |
|
| 31 |
alice = Adult( |
| 32 |
first_name='Alice', |
| 33 |
last_name='Smith', |
| 34 |
age=42, |
| 35 |
registered_voter=True, |
| 36 |
) |
| 37 |
|
| 38 |
alice.configure_traits() |