Ejemplo n.º 1
0
    def dock_control_for(self, parent, object):
        """ Returns the DockControl object for a specified object.
        """
        try:
            name = object.name
        except:
            try:
                name = object.label
            except:
                name = ""
        if name == "":
            name = user_name_for(object.__class__.__name__)

        image = None
        export = ""
        if isinstance(object, DockControl):
            dock_control = object
            image = dock_control.image
            export = dock_control.export
            dockable = dock_control.dockable
            close = dockable.dockable_should_close()
            if close:
                dock_control.close(force=True)

            control = dockable.dockable_get_control(parent)

            # If DockControl was closed, then reset it to point to the new
            # control:
            if close:
                dock_control.trait_set(control=control,
                                       style=parent.owner.style)
                dockable.dockable_init_dockcontrol(dock_control)
                return dock_control

        elif isinstance(object, IDockable):
            dockable = object
            control = dockable.dockable_get_control(parent)
        else:
            ui = object.get_dockable_ui(parent)
            dockable = DockableViewElement(ui=ui)
            export = ui.view.export
            control = ui.control

        dc = DockControl(
            control=control,
            name=name,
            export=export,
            style=parent.owner.style,
            image=image,
            closeable=True,
        )

        dockable.dockable_init_dockcontrol(dc)

        return dc
Ejemplo n.º 2
0
 def resynch_editor(self):
     """Resynchronizes the contents of the editor when the object trait
     changes externally to the editor.
     """
     button = self._button
     if button is not None:
         label = self.factory.label
         if label == "":
             label = user_name_for(self.name)
         button.SetLabel(label)
         button.Enable(isinstance(self.value, HasTraits))
Ejemplo n.º 3
0
 def resynch_editor ( self ):
     """ Resynchronizes the contents of the editor when the object trait
         changes externally to the editor.
     """
     button = self._button
     if button is not None:
         label = self.factory.label
         if label == '':
             label = user_name_for( self.name )
         button.SetLabel( label )
         button.Enable( isinstance( self.value, HasTraits ) )