PageRenderTime 18ms CodeModel.GetById 7ms app.highlight 6ms RepoModel.GetById 2ms app.codeStats 0ms

/src/examples/Level2/InteractiveFeatureTree/utils.py

http://pythonocc.googlecode.com/
Python | 55 lines | 27 code | 4 blank | 24 comment | 1 complexity | b4b2f79e3eb68acadf2e2f93b5e50698 MD5 | raw file
 1#!/usr/bin/env python
 2
 3##Copyright 2009-2011, Bryan Cole (bryancole.cam@googlemail.com)
 4##
 5##This file is part of pythonOCC.
 6##
 7##pythonOCC is free software: you can redistribute it and/or modify
 8##it under the terms of the GNU Lesser General Public License as published by
 9##the Free Software Foundation, either version 3 of the License, or
10##(at your option) any later version.
11##
12##pythonOCC is distributed in the hope that it will be useful,
13##but WITHOUT ANY WARRANTY; without even the implied warranty of
14##MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15##GNU Lesser General Public License for more details.
16##
17##You should have received a copy of the GNU Lesser General Public License
18##along with pythonOCC.  If not, see <http://www.gnu.org/licenses/>.
19
20
21from enthought.traits.api import (Range as _Range, 
22                                  Tuple as _Tuple,
23                                  Int as _Int,
24                                  Float as _Float)
25from enthought.traits.ui.api import TupleEditor
26
27class EditorTraits(object):
28    """
29    This mixin allows you to specify traits for the default trait editor
30    in the trait declaration.
31    
32    I've also changed the defaults for auto_set = False, enter_set=True.
33    'auto_set=True' gets really annoying.
34    """
35    def get_editor(self, *args, **kwds):
36        e = super(EditorTraits, self).get_editor(*args, **kwds)
37        editor_t = {'auto_set':False,
38                    'enter_set':True}
39        metadata = self._metadata
40        if 'editor_traits' in metadata:
41            editor_t.update(metadata['editor_traits'])
42        e.set(**editor_t)
43        return e
44
45class Range(EditorTraits, _Range):
46    pass
47    
48class Tuple(EditorTraits, _Tuple):
49    pass
50
51class Int(EditorTraits, _Int):
52    pass
53
54class Float(EditorTraits, _Float):
55    pass