Exemplo n.º 1
0
    def init(self, parent):
        """Finishes initializing the editor by creating the underlying toolkit
        widget.
        """
        from pyface.ui.wx.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.sync_value(self.factory.image_value, "image", "from")
        self.set_tooltip()
Exemplo n.º 2
0
class CustomEditor(SimpleEditor):
    """ Custom style editor for a button, which can contain an image.
    """
    #: The button image
    image = Image()

    def init(self, parent):
        """ Finishes initializing the editor by creating the underlying toolkit
            widget.
        """
        from pyface.ui.wx.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.sync_value(self.factory.image_value, "image", "from")
        self.set_tooltip()

    def _label_changed(self, label):
        self._control.label = self.string_value(label)

    @observe("image")
    def _image_updated(self, event):
        image = event.new
        self._control.image = image

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

        super().dispose()
Exemplo n.º 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
        from pyface.ui.wx.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()

    #---------------------------------------------------------------------------
    #  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()
Exemplo n.º 4
0
    def init(self, parent):
        """ Finishes initializing the editor by creating the underlying toolkit
            widget.
        """
        #from pyface.image_button import ImageButton
        from pyface.ui.wx.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()