File: dock_control_feature.py

package info (click to toggle)
enthought-traits-ui 2.0.5-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 15,204 kB
  • ctags: 9,623
  • sloc: python: 45,547; sh: 32; makefile: 19
file content (52 lines) | stat: -rw-r--r-- 1,903 bytes parent folder | download
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
#-------------------------------------------------------------------------------
#  
#  Initializes any trait of an object with 'dock_control = True' metadata
#  to point to the object's DockControl.
#  
#  Written by: David C. Morrill
#  
#  Date: 07/16/2006
#  
#  (c) Copyright 2006 by David C. Morrill
#  
#-------------------------------------------------------------------------------

#-------------------------------------------------------------------------------
#  Imports:
#-------------------------------------------------------------------------------
    
from enthought.traits.api \
    import HasTraits
    
from enthought.pyface.dock.api \
    import DockWindowFeature
    
#-------------------------------------------------------------------------------
#  'DockControlFeature' class:
#-------------------------------------------------------------------------------

class DockControlFeature ( DockWindowFeature ):

#-- Overidable Class Methods ---------------------------------------------------

    #---------------------------------------------------------------------------
    #  Returns a feature object for use with the specified DockControl (or None 
    #  if the feature does not apply to the DockControl object):   
    #---------------------------------------------------------------------------

    def feature_for ( cls, dock_control ):
        """ Returns a feature object for use with the specified DockControl (or
            None if the feature does not apply to the DockControl object).
        """
        object = dock_control.object
        if isinstance( object, HasTraits ):
            for name in object.trait_names( dock_control = True ):
                try:
                    setattr( object, name, dock_control )
                except:
                    pass
            
        return None
        
    feature_for = classmethod( feature_for )