Debian Codegraph @

traitsui/examples/demo/Standard_Editors/ArrayEditor_demo.py

raw
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 """Demo of the ArrayEditor"""
12
13 import numpy as np
14
15 from traits.api import Array, HasPrivateTraits
16 from traitsui.api import ArrayEditor, Item, View
17 from traitsui.menu import NoButtons
18
19
20 class ArrayEditorTest(HasPrivateTraits):
21
22 three = Array(np.int64, (3, 3))
23
24 four = Array(
25 np.float64,
26 (4, 4),
27 editor=ArrayEditor(width=-50),
28 )
29
30 view = View(
31 Item('three', label='3x3 Integer'),
32 '_',
33 Item('three', label='Integer Read-only', style='readonly'),
34 '_',
35 Item('four', label='4x4 Float'),
36 '_',
37 Item('four', label='Float Read-only', style='readonly'),
38 buttons=NoButtons,
39 resizable=True,
40 )
41
42
43 demo = ArrayEditorTest()
44
45 if __name__ == '__main__':
46 demo.configure_traits()