Esempio n. 1
0
class CustomEditor ( SimpleEditor ):
    """ Custom style editor for a button, which can contain an image.
    """

    #-- Public Methods ---------------------------------------------------------

    def init ( self, parent ):
        """ Finishes initializing the editor by creating the underlying toolkit
            widget.
        """
        from facets.ui.controls.image_button import ImageButton

        factory       = self.factory
        self._control = ImageButton(
            parent,
            label          = self.string_value( factory.label ),
            image          = factory.image,
            image_size     = factory.image_size,
            style          = factory.style,
            orientation    = factory.orientation,
            width_padding  = factory.width_padding,
            height_padding = factory.height_padding
        )
        self.adapter = self._control.control
        self._control.on_facet_set( self.update_object, 'clicked',
                                    dispatch = 'ui' )

        self.set_tooltip()


    def dispose ( self ):
        """ Disposes of the contents of an editor.
        """
        self._control.on_facet_set( self.update_object, 'clicked',
                                    remove = True )

        super( CustomEditor, self ).dispose()

#-- EOF ------------------------------------------------------------------------
Esempio n. 2
0
    def init ( self, parent ):
        """ Finishes initializing the editor by creating the underlying toolkit
            widget.
        """
        from facets.ui.controls.image_button import ImageButton

        factory       = self.factory
        self._control = ImageButton(
            parent,
            label          = self.string_value( factory.label ),
            image          = factory.image,
            image_size     = factory.image_size,
            style          = factory.style,
            orientation    = factory.orientation,
            width_padding  = factory.width_padding,
            height_padding = factory.height_padding
        )
        self.adapter = self._control.control
        self._control.on_facet_set( self.update_object, 'clicked',
                                    dispatch = 'ui' )

        self.set_tooltip()