~ubuntu-branches/ubuntu/trusty/python-traitsui/trusty

« back to all changes in this revision

Viewing changes to traitsui/wx/image_editor.py

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2011-07-09 13:57:39 UTC
  • Revision ID: james.westby@ubuntu.com-20110709135739-x5u20q86huissmn1
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#-------------------------------------------------------------------------------
 
2
#
 
3
#  Copyright (c) 2007, Enthought, Inc.
 
4
#  All rights reserved.
 
5
#
 
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
 
10
#
 
11
#  Thanks for using Enthought open source!
 
12
#
 
13
#  Author: David C. Morrill
 
14
#  Date:   06/05/2007
 
15
#
 
16
#-------------------------------------------------------------------------------
 
17
 
 
18
""" Traits UI 'display only' image editor.
 
19
"""
 
20
 
 
21
#-------------------------------------------------------------------------------
 
22
#  Imports:
 
23
#-------------------------------------------------------------------------------
 
24
 
 
25
from pyface.image_resource \
 
26
    import ImageResource
 
27
 
 
28
from traitsui.ui_traits \
 
29
    import convert_bitmap
 
30
 
 
31
# FIXME: ImageEditor is a proxy class defined here just for backward
 
32
# compatibility. The class has been moved to the
 
33
# traitsui.editors.image_editor file.
 
34
from traitsui.editors.image_editor \
 
35
    import ImageEditor
 
36
 
 
37
from editor \
 
38
    import Editor
 
39
 
 
40
from image_control \
 
41
    import ImageControl
 
42
 
 
43
#-------------------------------------------------------------------------------
 
44
#  '_ImageEditor' class:
 
45
#-------------------------------------------------------------------------------
 
46
 
 
47
class _ImageEditor ( Editor ):
 
48
    """ Traits UI 'display only' image editor.
 
49
    """
 
50
 
 
51
    #---------------------------------------------------------------------------
 
52
    #  Finishes initializing the editor by creating the underlying toolkit
 
53
    #  widget:
 
54
    #---------------------------------------------------------------------------
 
55
 
 
56
    def init ( self, parent ):
 
57
        """ Finishes initializing the editor by creating the underlying toolkit
 
58
            widget.
 
59
        """
 
60
        image = self.factory.image
 
61
        if image is None:
 
62
            image = self.value
 
63
 
 
64
        self.control = ImageControl( parent, convert_bitmap( image ),
 
65
                                     padding = 0 )
 
66
 
 
67
        self.set_tooltip()
 
68
 
 
69
    #---------------------------------------------------------------------------
 
70
    #  Updates the editor when the object trait changes external to the editor:
 
71
    #---------------------------------------------------------------------------
 
72
 
 
73
    def update_editor ( self ):
 
74
        """ Updates the editor when the object trait changes externally to the
 
75
            editor.
 
76
        """
 
77
        if self.factory.image is None:
 
78
            value = self.value
 
79
            if isinstance( value, ImageResource ):
 
80
                self.control.Bitmap( convert_bitmap( value ) )
 
81
 
 
82
### EOF #######################################################################
 
83