| 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 |
from traits.api import HasTraits, Float, List |
| 12 |
from traitsui.api import View, Item, RangeEditor |
| 13 |
|
| 14 |
# Tests the Large Range Slider editor. It also tests the case where the |
| 15 |
# editor is embedded in a list. |
| 16 |
|
| 17 |
|
| 18 |
class TestRangeEditor(HasTraits): |
| 19 |
x = Float() |
| 20 |
low = Float(123.123) |
| 21 |
high = Float(1123.123) |
| 22 |
list = List( |
| 23 |
Float( |
| 24 |
editor=RangeEditor( |
| 25 |
low_name='low', |
| 26 |
high_name='high', |
| 27 |
# These force the large range |
| 28 |
# slider to be used. |
| 29 |
low=100.0, |
| 30 |
high=10000.123, |
| 31 |
) |
| 32 |
) |
| 33 |
) |
| 34 |
view = View( |
| 35 |
Item( |
| 36 |
name='x', |
| 37 |
editor=RangeEditor( |
| 38 |
low_name='low', |
| 39 |
high_name='high', |
| 40 |
# These force the large range |
| 41 |
# slider to be used. |
| 42 |
low=100.0, |
| 43 |
high=10000.123, |
| 44 |
), |
| 45 |
), |
| 46 |
Item('list'), |
| 47 |
resizable=True, |
| 48 |
) |
| 49 |
|
| 50 |
|
| 51 |
def test(): |
| 52 |
a = TestRangeEditor() |
| 53 |
a.x = 500 |
| 54 |
a.list.append(500) |
| 55 |
a.edit_traits() # Just close the resulting dialog. |
| 56 |
assert a.x == 500 |
| 57 |
assert a.list[0] == 500 |
| 58 |
|
| 59 |
|
| 60 |
test() |