1
#-------------------------------------------------------------------------------
3
# Copyright (c) 2009, Enthought, Inc.
6
# This software is provided without warranty under the terms of the BSD
7
# license included in enthought/LICENSE.txt and may be redistributed only
8
# under the conditions described in the aforementioned license. The license
9
# is also available online at http://www.enthought.com/licenses/BSD.txt
11
# Thanks for using Enthought open source!
13
# Author: Evan Patterson
16
#-------------------------------------------------------------------------------
18
""" Traits UI 'display only' image editor.
21
#-------------------------------------------------------------------------------
23
#-------------------------------------------------------------------------------
25
from pyface.qt import QtGui
27
from pyface.image_resource \
30
from traitsui.ui_traits \
33
# FIXME: ImageEditor is a proxy class defined here just for backward
34
# compatibility. The class has been moved to the
35
# traitsui.editors.image_editor file.
36
from traitsui.editors.image_editor \
42
#-------------------------------------------------------------------------------
43
# '_ImageEditor' class:
44
#-------------------------------------------------------------------------------
46
class _ImageEditor ( Editor ):
47
""" Traits UI 'display only' image editor.
50
#---------------------------------------------------------------------------
51
# Finishes initializing the editor by creating the underlying toolkit
53
#---------------------------------------------------------------------------
55
def init ( self, parent ):
56
""" Finishes initializing the editor by creating the underlying toolkit
59
image = self.factory.image
63
self.control = QtGui.QLabel()
64
self.control.setPixmap( convert_bitmap( image ) )
68
#---------------------------------------------------------------------------
69
# Updates the editor when the object trait changes external to the editor:
70
#---------------------------------------------------------------------------
72
def update_editor ( self ):
73
""" Updates the editor when the object trait changes externally to the
76
if self.factory.image is None:
78
if isinstance( value, ImageResource ):
79
self.control.setPixmap( convert_bitmap( value ) )