Module cad_viewer_widget.widget

This module is the Python part of the CAD Viewer widget

Classes

class AnimationTrack (path, action, times, values)

Defining a three.js animation track.

Parameters

path : string
The path (or id) of the cad object for which this track is meant. Usually of the form /top-level/level2/...
action : {"t", "tx", "ty", "tz", "q", "rx", "ry", "rz"}

The action type:

  • "tx", "ty", "tz" for translations along the x, y or z-axis
  • "t" to add a position vector (3-dim array) to the current position of the CAD object
  • "rx", "ry", "rz" for rotations around x, y or z-axis
  • "q" to apply a quaternion to the location of the CAD object
times : list of float or int
An array of floats describing the points in time where CAD object (with id path) should be at the location defined by action and values
values : list of float or int

An array of same length as times defining the locations where the CAD objects should be according to the action provided. Formats:

  • "tx", "ty", "tz": float distance to move
  • "t": 3-dim tuples or lists defining the positions to move to
  • "rx", "ry", "rz": float angle in degrees
  • "q" quaternions of the form (x,y,z,w) the represent the rotation to be applied

Examples

AnimationTrack(
    '/bottom/left_middle/lower',                                # path
    'rz',                                                       # action
    [0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0],              # times (seconds)
    [-15.0, -15.0, -15.0, 9.7, 20.0, 9.7, -15.0, -15.0, -15.0]  # angles
)

AnimationTrack(
    'base/link_4_6',                                            # path
    't',                                                        # action
    [0.0, 1.0, 2.0, 3.0, 4.0],                                  # times (seconds)
    [[0.0, 0.0, 0.0], [0.0, 1.9509, 3.9049],
     [0.0 , -3.2974, -16.7545], [0.0 , 0.05894 , -32.0217],
     [0.0 , -3.2212, -13.3424]]                                 # 3-dim positions
)

See Also

Methods

def to_array(self)

Create an array representation of the animation track

Returns

array-like
The 4 dim array comprising of the instance variables path, action, times and values
class CadViewer (cad_width=800, height=600, tree_width=240, theme='browser', glass=False, tools=True, pinning=False, title=None, anchor=None)

The main class for the CAD Viewer encapsulating the three-cad-viewer Javascript module

Parameters

cad_width : int, default: 800
Width of the canvas element
height : int, default: 600
Height of the canvas element
tree_width : int, default: 240
Width of the navigation tree element
theme : string, default: 'light'
UI theme, can be 'dark' or 'light' (default)
tools : bool, default: True
Whether to show CAD tools (True) or not (False)
glass : bool, default: False
Whether to use glass mode (True) or not (False)
pinning : bool, default: False
Whether to allow replacing the CAD View by a canvas screenshot

See Also

Instance variables

var ambient_intensity

Get or set the CadViewerWidget traitlet ambient_intensity. see CadViewerWidget.ambient_intensity

var axes

Get or set the CadViewerWidget traitlet axes see CadViewerWidget.axes

var axes0

Get or set the CadViewerWidget traitlet axes0 see CadViewerWidget.axes0

var black_edges

Get or set the CadViewerWidget traitlet black_edges see CadViewerWidget.black_edges

var cad_width

Get or set the CadViewerWidget traitlet cad_width see CadViewerWidget.tools

var clip_intersection

Get or set the CadViewerWidget traitlet clip_intersection see CadViewerWidget.clip_intersection

var clip_normal_0

Get or set the CadViewerWidget traitlet clip_normal_0 see CadViewerWidget.clip_normal_0

var clip_normal_1

Get or set the CadViewerWidget traitlet clip_normal_1 see CadViewerWidget.clip_normal_1

var clip_normal_2

Get or set the CadViewerWidget traitlet clip_normal_2 see CadViewerWidget.clip_normal_2

var clip_planes

Get or set the CadViewerWidget traitlet clip_planes see CadViewerWidget.clip_planes

var clip_value_0

Get or set the CadViewerWidget traitlet clip_slider_0 see CadViewerWidget.clip_slider_0

var clip_value_1

Get or set the CadViewerWidget traitlet clip_slider_1 see CadViewerWidget.clip_slider_1

var clip_value_2

Get or set the CadViewerWidget traitlet clip_slider_2 see CadViewerWidget.clip_slider_2

var control

Get or set the CadViewerWidget traitlet control see CadViewerWidget.control

var debug

Get or set the CadViewerWidget traitlet debug see CadViewerWidget.debug

var default_edgecolor

Get or set the CadViewerWidget traitlet default_edgecolor see CadViewerWidget.default_edgecolor

var default_opacity

Get or set the CadViewerWidget traitlet default_opacity see CadViewerWidget.default_opacity

var direct_intensity

Get or set the CadViewerWidget traitlet direct_intensity see CadViewerWidget.direct_intensity

var disposed

Whether the Javascript viewer is disposed

var explode

Get or set the CadViewerWidget traitlet explode see CadViewerWidget.explode

var glass

Get or set the CadViewerWidget traitlet glass see CadViewerWidget.tools

var grid

Get or set the CadViewerWidget traitlet grid see CadViewerWidget.grid

var height

Get or set the CadViewerWidget traitlet height see CadViewerWidget.tools

var last_pick

Get or set the CadViewerWidget traitlet lastPick see CadViewerWidget.lastPick

var metalness

Get or set the CadViewerWidget traitlet metalness see CadViewerWidget.direct_intensity

var normal_len

Get or set the CadViewerWidget traitlet normal_len

var ortho

Get or set the CadViewerWidget traitlet ortho see CadViewerWidget.ortho

var pan_speed

Get or set the CadViewerWidget traitlet pan_speed see CadViewerWidget.pan_speed

var pinning

Get or set the CadViewerWidget traitlet pinning see CadViewerWidget.pinning

var position

Get or set the CadViewerWidget traitlet position see CadViewerWidget.position

var quaternion

Get or set the CadViewerWidget traitlet quaternion see CadViewerWidget.quaternion

var rotate_speed

Get or set the CadViewerWidget traitlet rotate_speed see CadViewerWidget.rotate_speed

var roughness

Get or set the CadViewerWidget traitlet roughness see CadViewerWidget.direct_intensity

var target

Get or set the CadViewerWidget traitlet target see CadViewerWidget.position

var tools

Get or set the CadViewerWidget traitlet tools see CadViewerWidget.tools

var transparent

Get or set the CadViewerWidget traitlet transparent see CadViewerWidget.transparent

var tree_width

Get or set the CadViewerWidget traitlet tree_width see CadViewerWidget.tools

var up

Get or set the CadViewerWidget traitlet up see CadViewerWidget.up

var zoom

Get or set the CadViewerWidget traitlet zoom see CadViewerWidget.zoom

var zoom_speed

Get or set the CadViewerWidget traitlet zoom_speed see CadViewerWidget.zoom_speed

Methods

def add_shapes(self, shapes, states, tracks=None, normal_len=0, default_edgecolor='#707070', default_opacity=0.5, ambient_intensity=1.0, direct_intensity=1.1, metalness=0.3, roughness=0.65, tools=None, glass=None, cad_width=None, tree_width=None, height=None, control='trackball', up='Z', ortho=True, axes=False, axes0=False, grid=None, explode=False, ticks=10, transparent=False, black_edges=False, collapse=1, position=None, quaternion=None, target=None, zoom=None, reset_camera='reset', zoom_speed=1.0, pan_speed=1.0, rotate_speed=1.0, timeit=False, debug=False)

Adding shapes to the CAD view

Parameters

shapes : dict
Nested tessellated shapes
states : dict
State of the nested cad objects, key = object path, value = 2-dim tuple of 0/1 (hidden/visible) for object and edges
tracks : list or tuple, default None
List of animation track arrays, see AnimationTrack.to_array
title : str, default: None
Name of the title view to display the shapes.
ortho : bool, default True
Whether to use orthographic view (True) or perspective view (False)
cad_width : int, default: None
Width of the canvas element
height : int, default: None
Height of the canvas element
tree_width : int, default: None
Width of the navigation tree element
tools : bool, default: None
Whether to show CAD tools (True) or not (False)
glass : bool, default: None
Whether to use glass mode (True) or not (False)
control : string, default 'trackball'
Whether to use trackball controls ('trackball') or orbit controls ('orbit')
up : string, default 'Z'
Whether camera up direction is Z ('Z') or Y ('Y') or the lagacy Z orientation ('L')
axes : bool, default False
Whether to show coordinate axes (True) or not (False)
axes0 : bool, default False
Whether to center coordinate axes at the origin [0,0,0] (True) or at the CAD object center (False)
grid : 3-dim list of bool, default None
Whether to show the grids for xy, xz, yz (None means (False, False, False))
explode : bool, default: None
Whether to show the explode widget (True) or not (False)
ticks : int, default 10
Hint for the number of ticks for the grids (will be adjusted for nice intervals)
transparent : bool, default False
Whether to show the CAD objects transparently (True) or not (False)
black_edges : bool, default False
Whether to shows the edges in black (True) or not(False)
collapse : int, default 0
Collapse CAD tree (1: collapse nodes with single leaf, 2: collapse all nodes)
normal_Len : int, default 0
If > 0, the vertex normals will be rendered with the length given be this parameter
default_edgecolor : string, default "#707070"
The default edge color in web format, e.g. '#707070'
default_opacity : float, default 0.5
The default opacity level for transparency between 0.0 an 1.0
ambient_intensity : float, default 1.0
The intensity of the ambient light
direct_intensity : float, default 1.1
The intensity of the direct light
metalness : float, default 0.3
The degree of material metalness
roughness : float, default 0.65
The degree of material roughness
position : 3-dim list of float, default None
Position of the camera as a 3-dim tuple of float (x,y,z)
quaternion : 4-dim list of float, default None
Rotation of the camera as 4-dim quaternion (x,y,z,w)
target : 3-dim list of float, default None
Camera target to look at, default is the center of the object's bounding box
zoom : float, default None
Zoom value of the camera
reset_camera : bool, default True
Keep the camera position and rotation when showing new shapes (True) or not (False)
zoom_speed : float, default 1.0
Speed of zooming with the mouse
pan_speed : float, default 1.0
Speed of panning with the mouse
rotate_speed : float, default 1.0
Speed of rotation with the mouse
timeit : bool, default False
Whether to output timing info to the browser console (True) or not (False)

Examples

A simple cube with edge len of 1 is tessellated like the shape element of the first (and only) element of the parts list:

shapes = {
    "name": "Group",
    "id": "/Group",
    "loc": None,  # would be (<position>, <quaternion>), e.g. ([0,0,0), (0,0,0,1)]),
    "bb": {
        "xmin": -0.5, "xmax": 0.5,
        "ymin": -0.5, "ymax": 0.5,
        "zmin": -0.5, "zmax": 0.5
    }
    "parts": [{
        "name": "Part_0",
        "id": "/Group/Part_0",
        "type": "shapes",
        "shape": {"vertices": [
            [-0.5, -0.5, -0.5], [-0.5, -0.5, 0.5], [-0.5, 0.5, -0.5], [-0.5, 0.5, 0.5],
            [0.5, -0.5, -0.5], [0.5, -0.5, 0.5], [0.5, 0.5, -0.5], [0.5, 0.5, 0.5],
            [-0.5, -0.5, -0.5], [0.5, -0.5, -0.5], [-0.5, -0.5, 0.5], [0.5, -0.5, 0.5],
            [-0.5, 0.5, -0.5], [0.5, 0.5, -0.5], [-0.5, 0.5, 0.5], [0.5, 0.5, 0.5],
            [-0.5, -0.5, -0.5], [-0.5, 0.5, -0.5], [0.5, -0.5, -0.5], [0.5, 0.5, -0.5],
            [-0.5, -0.5, 0.5], [-0.5, 0.5, 0.5], [0.5, -0.5, 0.5], [0.5, 0.5, 0.5]],
        "triangles": [
            1, 2, 0, 1, 3, 2, 5, 4, 6, 5, 6, 7, 11, 8, 9, 11, 10, 8, 15, 13,
            12, 15, 12, 14, 19, 16, 17, 19, 18, 16, 23, 21, 20, 23, 20, 22 ],
        "normals": [
            [-1, 0, 0], [-1, 0, 0], [-1, 0, 0], [-1, 0, 0],
            [1, 0, 0], [1, 0, 0], [1, 0, 0], [1, 0, 0],
            [0, -1, 0], [0, -1, 0], [0, -1, 0], [0, -1, 0],
            [0, 1, 0], [0, 1, 0], [0, 1, 0], [0, 1, 0],
            [0, 0, -1], [0, 0, -1], [0, 0, -1], [0, 0, -1],
            [0, 0, 1], [0, 0, 1], [0, 0, 1], [0, 0, 1]
        ],
        "edges": [
            [[-0.5, -0.5, -0.5], [-0.5, -0.5, 0.5]],
            [[-0.5, -0.5, 0.5], [-0.5, 0.5, 0.5]],
            [[-0.5, 0.5, -0.5], [-0.5, 0.5, 0.5]],
            [[-0.5, -0.5, -0.5], [-0.5, 0.5, -0.5]],
            [[0.5, -0.5, -0.5], [0.5, -0.5, 0.5]],
            [[0.5, -0.5, 0.5], [0.5, 0.5, 0.5]],
            [[0.5, 0.5, -0.5], [0.5, 0.5, 0.5]],
            [[0.5, -0.5, -0.5], [0.5, 0.5, -0.5]],
            [[-0.5, -0.5, -0.5], [0.5, -0.5, -0.5]],
            [[-0.5, -0.5, 0.5], [0.5, -0.5, 0.5]],
            [[-0.5, 0.5, -0.5], [0.5, 0.5, -0.5]],
            [[-0.5, 0.5, 0.5], [0.5, 0.5, 0.5]]
        ]},
        "color": "#e8b024",
        "renderback": false
    }]
}
states = {'/Group/Part_0': [1, 1]}

A nested object (with shapes shortened) looks like:

{
    'id': '/bottom', 'name': 'bottom', 'loc': ['<position>', '<quaternion>'],
    'parts': [{
            'id': '/bottom/bottom_0', 'name': 'bottom_0', 'type': 'shapes', 'color': '#bfbfbf',
            'shape': {'vertices': [...], 'triangles': [...], 'normals': [...], 'edges': [...]},
        }, {
            'id': '/bottom/top', 'name': 'top', 'loc': ['<position>', '<quaternion>'],
            'parts': [{
                'id': '/bottom/top/top_0', 'name': 'top_0', 'type': 'shapes', 'color': '#bfbfbf',
                'shape': {'vertices': [...], 'triangles': [...], 'normals': [...], 'edges': [...]},
            }]
        }, {
            'id': '/bottom/front_stand', 'name': 'front_stand', 'loc': ['<position>', '<quaternion>'],
            'parts': [{
                'id': '/bottom/front_stand/front_stand_0', 'name': 'front_stand_0', 'type': 'shapes', 'color': '#7fcce5',
                'shape': {'vertices': [...], 'triangles': [...], 'normals': [...], 'edges': [...]},
            }]
        }, {
            'id': '/bottom/back_stand', 'name': 'back_stand', 'loc': ['<position>', '<quaternion>'],
            'parts': [{
                'id': '/bottom/back_stand/back_stand_0', 'name': 'back_stand_0', 'type': 'shapes', 'color': '#7fcce5',
                'shape': {'vertices': [...], 'triangles': [...], 'normals': [...], 'edges': [...]},
            }]
        }, {
            'id': '/bottom/right_back', 'name': 'right_back', 'loc': ['<position>', '<quaternion>'],
            'parts': [{
                'id': '/bottom/right_back/right_back_0', 'name': 'right_back_0', 'type': 'shapes', 'color': '#ffa500',
                'shape': {'vertices': [...], 'triangles': [...], 'normals': [...], 'edges': [...]},
            }, {
                'id': '/bottom/right_back/lower', 'name': 'lower', 'loc': ['<position>', '<quaternion>'],
                'parts': [{
                    'id': '/bottom/right_back/lower/lower_0', 'name': 'lower_0', 'type': 'shapes', 'color': '#ffa500',
                    'shape': {'vertices': [...], 'triangles': [...], 'normals': [...], 'edges': [...]},
                }]
            }]
        },
        ...
    ]
}
states = {
    '/bottom/bottom_0': [1, 1],
    '/bottom/top/top_0': [1, 1],
    '/bottom/front_stand/front_stand_0': [1, 1],
    '/bottom/back_stand/back_stand_0': [1, 1],
    '/bottom/right_back/right_back_0': [1, 1],
    '/bottom/right_back/lower/lower_0': [1, 1],
    ...
}

Notes

Vector : float[3] := [x, y, z] VectorList : Vector[n] := [ [x0, y0, z0], [x1, xy1, z1], … ] Index : int[m] := [ i0, i1, i2, … ] Edge : Vector[2] := [ [x0, y0, z0], [x1, xy1, z1]] EdgeList : Edge[k] := [ [[x0, y0, z0], [x1, xy1, z1]], [[x2, y2, z2], [x3, xy3, z3]], … ]

Shape, Faces := { "id": "", "name": "", "type": "shapes", "color": "#ffffff", "renderback": false "shape": { "vertices": , "triangles": , "normals": , "edges": } }

Edges := { "id": ">", "name": "", "type": "edges", "color": "#ffffff", "width": 3, "renderback": false "shape": }

Vertices := { "id": ">", "name": "", "type": "vertices", "color": "#ffffff", "size": 6 "shape": }

def add_track(self, track)

Add an animation track to CAD view

Parameters

track : AnimationTrack
Animation track, see AnimationTrack
def add_tracks(self, tracks)

Add a list of animation tracks to CAD view

Parameters

tracks : list of AnimationTrack
List of Animation tracks, see AnimationTrack
def animate(self, speed=1)

Send animation tracks to CAD view

Parameters

speed : float, default: 1
Animation speed, will be forwarded via animation_speed traitlet
def clear_tracks(self)

Remove animation tracks from CAD view

def close(self)

Close the underlying Javascript viewer

def dispose(self)

Dispose the CAD Viewer

def dump_model(self, shapes=False)
def execute(self, method, args=None)

Execute a method of a Javascript object

Parameters

method : string
A 'CadViewer' object based Javascrip object path, e.g. abc.def[3].method(args) where abc.def[3] is the object notation relative to the 'CadViewer' object and method is the method to call
args : list of any
The arguments passed to abc.def[3].method(args)
def export_html(self, filename='cadquery.html', title='CadQuery')
def export_png(self, filename)

Save CAD View as PNG

def pause(self)

Pause or unpause animation

def pin_as_png(self)

Pin CAD View as PNG

def play(self)

Start or unpause animation

def remove_ui_elements(self, elements)
def rotate_left(self, angle)

Rotate CAD obj to the left (positive angle) and right (negative angle) - orbit controls only

Parameters

angle : float
The rotation angle in degrees
def rotate_up(self, angle)

Rotate CAD obj up (positive angle) and down (negative angle) - orbit controls only

Parameters

angle : float
The rotation angle in degrees
def rotate_x(self, angle)

Rotate CAD obj around x-axis - trackball controls only

Parameters

angle : float
The rotation angle in degrees
def rotate_y(self, angle)

Rotate CAD obj around y-axis - trackball controls only

Parameters

angle : float
The rotation angle in degrees
def rotate_z(self, angle)

Rotate CAD obj around z-axis - trackball controls only

Parameters

angle : float
The rotation angle in degrees
def select_clipping(self)

Select Clipping tab

def select_tree(self)

Select Navigation tree tab

def set_camera(self, direction)

Set camera to one of the predefined locations

Parameters

direction : string
one of ["iso", "top", "bottom", "left", "right", "front", "rear"]
def status(self, shapes=False)
def stop(self)

Stop animation

def update_camera_location(self)

Sync position, quaternion and zoom of camera to Python

def update_states(self, states)

Set navigation tree states for a CAD view

class CadViewerWidget (**kwargs)

The CAD Viewer widget.

Public constructor

Ancestors

  • ipywidgets.widgets.widget_output.Output
  • ipywidgets.widgets.domwidget.DOMWidget
  • ipywidgets.widgets.widget.Widget
  • ipywidgets.widgets.widget.LoggingHasTraits
  • traitlets.traitlets.HasTraits
  • traitlets.traitlets.HasDescriptors

Instance variables

var ambient_intensity

float: The intensity of the ambient light

var anchor

unicode string whether to add a view to the right sidebar ('right') or as a tab to the main window ('tab')

var animation_speed

float: Animation speed

var axes

bool: Whether to show coordinate axes (True) or not (False)

var axes0

bool: Whether to center coordinate axes at the origin [0,0,0] (True) or at the CAD object center (False)

var black_edges

bool: Whether to shows the edges in black (True) or not(False)

var cad_width

unicode string: Width of the canvas element

var clip_intersection

bool: Whether to use intersection clipping (True) or not (False)

var clip_normal_0

tuple: Normal of clipping plane 1 as a 3-dim tuple of float (x,y,z)

var clip_normal_1

tuple: Normal of clipping plane 2 as a 3-dim tuple of float (x,y,z)

var clip_normal_2

tuple: Normal of clipping plane 3 as a 3-dim tuple of float (x,y,z)

var clip_planes

bool: Whether to show colored clipping planes (True) or not (False)

var clip_slider_0

float: Slider value of clipping plane 1

var clip_slider_1

float: Slider value of clipping plane 2

var clip_slider_2

float: Slider value of clipping plane 3

var collapse

Enum Collapse: Collapse CAD tree (1: collapse nodes with single leaf, 2: collapse all nodes)

var control

unicode: Whether to use trackball controls ('trackball') or orbit controls ('orbit')

var debug

bool: Whether to show infos in the browser console (True) or not (False)

var default_edgecolor

unicode: The default edge color in web format, e.g. '#ffaa88'

var default_opacity

unicode: The default opacity for transparent objects

var direct_intensity

float: The intensity of the direct light

var disposed

unicode string: Whether the Javascript viewer is disposed

var explode

bool: Whether to use showthe explode menu or not (False)

var glass

bool: Whether to use the glass mode (CAD navigation as transparent overlay) or not

var grid

tuple: Whether to show the grids for xy, xz, yz.

var height

int: Height of the canvas element

var image_id

unicode string: the id of the image tag to use for pin as png

var initialize

bool: internally used to control initialization of view. Do not use!

var lastPick

dict: Describes the last picked element of the CAD view

var metalness

float: The degree of metalness

var normal_len

float: If > 0, the vertex normals will be rendered with the length given be this parameter

var ortho

bool: Whether to use orthographic view (True) or perspective view (False)

var pan_speed

float: Speed of panning with the mouse

var pinning

bool: Whether to show the pin a png button or not

var position

tuple: Position of the camera as a 3-dim tuple of float (x,y,z)

var position0

tuple: Initial position of the camera as a 3-dim tuple of float (x,y,z)

var quaternion

tuple: Rotation of the camera as 4-dim quaternion (x,y,z,w)

var quaternion0

tuple: Initial rotation of the camera as 4-dim quaternion (x,y,z,w)

var reset_camera

Enum Camera: Whether to reset camera (Camera.RESET) or not (Camera.KEEP or Camera.CENTER keep orientation but center the camera)

var result

unicode string: JSON serialized result from Javascript

var rotate_speed

float: Speed of rotation with the mouse

var roughness

float: The degree of roughness

var shapes

unicode: Serialized nested tessellated shapes

var state_updates

dict: Dict with paths as key and a 2-dim tuple of 0/1 (hidden/visible) for object and edges

var states

dict: State of the nested cad objects, key = object path, value = 2-dim tuple of 0/1 (hidden/visible) for object and edges

var tab

unicode: Whether to show the navigation tree ('tree') or the clipping UI ('clip')

var target

tuple: Camera target to look at as 3-dim tuple (x,y,z)

var target0

tuple: Initial camera target to look at as 3-dim tuple (x,y,z)

var theme

unicode string: UI theme, can be 'dark' or 'light' (default)

var ticks

integer: Hint for the number of ticks for the grids (will be adjusted for nice intervals)

var timeit

bool: Whether to output timing info to the browser console (True) or not (False)

var title

unicode string of the title of the sidecar to be used. None means CAD view will be opened in cell

var tools

bool: Whether to show CAD tools (True) or not (False)

var tracks

unicode: Serialized list of animation track arrays, see AnimationTrack.to_array

var transparent

bool: Whether to show the CAD objects transparently (True) or not (False)

var tree_width

int: Width of the navigation tree element

var up

unicode: Whether camera up direction is Z ('Z') or Y ('Y') or the legacy Z orientation ('L')

var zoom

float: Zoom value of the camera

var zoom0

float: Initial zoom value of the camera

var zoom_speed

float: Speed of zooming with the mouse

Methods

def func(...)
class Camera (values, default_value=traitlets.Undefined, **kwargs)

An enum whose value must be in a given sequence.

Declare a traitlet.

If allow_none is True, None is a valid value in addition to any values that are normally valid. The default is up to the subclass. For most trait types, the default value for allow_none is False.

If read_only is True, attempts to directly modify a trait attribute raises a TraitError.

Extra metadata can be associated with the traitlet using the .tag() convenience method or by using the traitlet instance's .metadata dictionary.

Ancestors

  • traitlets.traitlets.Enum
  • traitlets.traitlets.TraitType
  • traitlets.traitlets.BaseDescriptor

Class variables

var CENTER
var KEEP
var RESET
class Collapse (values, default_value=traitlets.Undefined, **kwargs)

An enum whose value must be in a given sequence.

Declare a traitlet.

If allow_none is True, None is a valid value in addition to any values that are normally valid. The default is up to the subclass. For most trait types, the default value for allow_none is False.

If read_only is True, attempts to directly modify a trait attribute raises a TraitError.

Extra metadata can be associated with the traitlet using the .tag() convenience method or by using the traitlet instance's .metadata dictionary.

Ancestors

  • traitlets.traitlets.Enum
  • traitlets.traitlets.TraitType
  • traitlets.traitlets.BaseDescriptor

Class variables

var ALL
var LEAVES
var NONE
var ROOT