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