/usr/share/doc/python-traits/examples/tutorials/doc_examples/examples/mapped.py is in python-traits 4.1.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | # Copyright (c) 2007, Enthought, Inc.
# License: BSD Style.
# mapped.py --- Example of a mapped trait
#--[Imports]--------------------------------------------------------------------
from traits.api import HasTraits, Trait
#--[Code]-----------------------------------------------------------------------
standard_color = Trait ('black', {
'black': ( 0.0, 0.0, 0.0, 1.0 ),
'blue': ( 0.0, 0.0, 1.0, 1.0 ),
'cyan': ( 0.0, 1.0, 1.0, 1.0 ),
'green': ( 0.0, 1.0, 0.0, 1.0 ),
'magenta': ( 1.0, 0.0, 1.0, 1.0 ),
'orange': ( 0.8, 0.196, 0.196, 1.0 ),
'purple': ( 0.69, 0.0, 1.0, 1.0 ),
'red': ( 1.0, 0.0, 0.0, 1.0 ),
'violet': ( 0.31, 0.184, 0.31, 1.0 ),
'yellow': ( 1.0, 1.0, 0.0, 1.0 ),
'white': ( 1.0, 1.0, 1.0, 1.0 ),
'transparent': ( 1.0, 1.0, 1.0, 0.0 )
} )
red_color = Trait( 'red', standard_color )
class GraphicShape( HasTraits ):
line_color = standard_color
fill_color = red_color
#--[Example*]-------------------------------------------------------------------
my_shape1 = GraphicShape()
# Default values for normal trait attributes
print my_shape1.line_color, my_shape1.fill_color
# Output: black red
# Default values for shadow trait attributes
print my_shape1.line_color_, my_shape1.fill_color_
# Output: (0.0, 0.0, 0.0, 1.0) (1.0, 0.0, 0.0, 1.0)
# Non-default values
my_shape2 = GraphicShape()
my_shape2.line_color = 'blue'
my_shape2.fill_color = 'green'
print my_shape2.line_color, my_shape2.fill_color
# Output: blue green
print my_shape2.line_color_, my_shape2.fill_color_
# Output: (0.0, 0.0, 1.0, 1.0) (0.0, 1.0, 0.0, 1.0)
|