コード例 #1
0
ファイル: button_editor.py プロジェクト: tkoyama010/traitsui
    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
ファイル: button_editor.py プロジェクト: robmcmullen/traitsui
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
ファイル: button_editor.py プロジェクト: robmcmullen/traitsui
    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
ファイル: button_editor.py プロジェクト: timdiller/traitsui
    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()