Example #1
0
class _ImageEditor(Editor):
    """ Traits UI 'display only' image editor.
    """

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

    def init(self, parent):
        """ Finishes initializing the editor by creating the underlying toolkit
            widget.
        """
        image = self.factory.image
        if image is None:
            image = self.value

        self.control = ImageControl(parent, convert_bitmap(image), padding=0)

        self.set_tooltip()

    #---------------------------------------------------------------------------
    #  Updates the editor when the object trait changes external to the editor:
    #---------------------------------------------------------------------------

    def update_editor(self):
        """ Updates the editor when the object trait changes externally to the
            editor.
        """
        if self.factory.image is None:
            value = self.value
            if isinstance(value, ImageResource):
                self.control.Bitmap(convert_bitmap(value))
Example #2
0
class ReadonlyEditor(Editor):
    """ Read-only style of image enumeration editor, which displays a single
    ImageControl, representing the object trait's value.
    """

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

    def init(self, parent):
        """ Finishes initializing the editor by creating the underlying toolkit
            widget.
        """
        self.control = ImageControl(
            parent,
            bitmap_cache(
                '%s%s%s' %
                (self.factory.prefix, self.str_value, self.factory.suffix),
                False, self.factory._image_path))

    #---------------------------------------------------------------------------
    #  Updates the editor when the object trait changes external to the editor:
    #---------------------------------------------------------------------------

    def update_editor(self):
        """ Updates the editor when the object trait changes externally to the
            editor.
        """
        self.control.Bitmap(
            bitmap_cache(
                '%s%s%s' %
                (self.factory.prefix, self.str_value, self.factory.suffix),
                False, self.factory._image_path))
Example #3
0
class ReadonlyEditor(Editor):

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

    def init(self, parent):
        """ Finishes initializing the editor by creating the underlying toolkit
            widget.
        """
        self.control = ImageControl(
            parent,
            bitmap_cache(self.str_value + self.factory.suffix, False,
                         self.factory._image_path))

    #---------------------------------------------------------------------------
    #  Updates the editor when the object trait changes external to the editor:
    #---------------------------------------------------------------------------

    def update_editor(self):
        """ Updates the editor when the object trait changes external to the 
            editor.
        """
        self.control.Bitmap(
            bitmap_cache(self.str_value + self.factory.suffix, False,
                         self.factory._image_path))