예제 #1
0
    def init(self, parent):
        """ Finishes initializing the editor by creating the underlying toolkit
            widget.
        """
        from pyface.image_button import ImageButton

        factory = self.factory
        if self.factory.label:
            label = self.factory.label
        else:
            label = self.item.get_label(self.ui)

        self._control = ImageButton(
            parent,
            label=self.string_value(label),
            image=factory.image,
            style=factory.style,
            orientation=factory.orientation,
            width_padding=factory.width_padding,
            height_padding=factory.height_padding,
        )
        self.control = self._control.control
        self._control.on_trait_change(self.update_object,
                                      "clicked",
                                      dispatch="ui")
        self.sync_value(self.factory.label_value, "label", "from")

        self.set_tooltip()
예제 #2
0
class CustomEditor(SimpleEditor):
    """ Custom style editor for a button, which can contain an image.
    """

    #-------------------------------------------------------------------------
    #  Finishes initializing the editor by creating the underlying toolkit
    #  widget:
    #-------------------------------------------------------------------------

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

        factory = self.factory
        if self.factory.label:
            label = self.factory.label
        else:
            label = self.item.get_label(self.ui)

        self._control = ImageButton(parent,
                                    label=self.string_value(label),
                                    image=factory.image,
                                    style=factory.style,
                                    orientation=factory.orientation,
                                    width_padding=factory.width_padding,
                                    height_padding=factory.height_padding)
        self.control = self._control.control
        self._control.on_trait_change(self.update_object,
                                      'clicked',
                                      dispatch='ui')
        self.sync_value(self.factory.label_value, 'label', 'from')

        self.set_tooltip()

    #-------------------------------------------------------------------------
    #  Disposes of the contents of an editor:
    #-------------------------------------------------------------------------

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

        super(CustomEditor, self).dispose()
예제 #3
0
class CustomEditor(SimpleEditor):
    """ Custom style editor for a button, which can contain an image.
    """

    #-------------------------------------------------------------------------
    #  Finishes initializing the editor by creating the underlying toolkit
    #  widget:
    #-------------------------------------------------------------------------

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

        factory = self.factory
        if self.factory.label:
            label = self.factory.label
        else:
            label = self.item.get_label(self.ui)

        self._control = ImageButton(
            parent,
            label=self.string_value(label),
            image=factory.image,
            style=factory.style,
            orientation=factory.orientation,
            width_padding=factory.width_padding,
            height_padding=factory.height_padding
        )
        self.control = self._control.control
        self._control.on_trait_change(self.update_object, 'clicked',
                                      dispatch='ui')
        self.sync_value(self.factory.label_value, 'label', 'from')

        self.set_tooltip()

    #-------------------------------------------------------------------------
    #  Disposes of the contents of an editor:
    #-------------------------------------------------------------------------

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

        super(CustomEditor, self).dispose()
예제 #4
0
    def init(self, parent):
        """ Finishes initializing the editor by creating the underlying toolkit
            widget.
        """
        from pyface.image_button import ImageButton

        factory = self.factory
        if self.factory.label:
            label = self.factory.label
        else:
            label = self.item.get_label(self.ui)

        self._control = ImageButton(
            parent,
            label=self.string_value(label),
            image=factory.image,
            style=factory.style,
            orientation=factory.orientation,
            width_padding=factory.width_padding,
            height_padding=factory.height_padding
        )
        self.control = self._control.control
        self._control.on_trait_change(self.update_object, 'clicked',
                                      dispatch='ui')
        self.sync_value(self.factory.label_value, 'label', 'from')

        self.set_tooltip()
예제 #5
0
    def init ( self, parent ):
        """ Finishes initializing the editor by creating the underlying toolkit
            widget.
        """
        from pyface.image_button import ImageButton

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