#------------------------------------------------------------------------------
# Copyright (c) 2013, Nucleic Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
#------------------------------------------------------------------------------
""" An example of the `ImageView` widget.
This example shows how a PNG image (in an enaml Image object) can displayed.
<< autodoc-me >>
"""
import os
from enaml.image import Image
from enaml.layout.api import vbox, hbox, spacer
from enaml.widgets.api import Window, Container, ComboBox, ImageView
def image_path(name):
dirname = os.path.dirname(__file__)
return os.path.join(dirname, 'images', name)
IMAGES = {
'Image A': Image(data=open(image_path('img1.png'), 'rb').read()),
'Image B': Image(data=open(image_path('img2.png'), 'rb').read()),
'Image C': Image(data=open(image_path('img3.png'), 'rb').read()),
}
enamldef Main(Window):
Container:
constraints = [
vbox(hbox(cbox, spacer), img),
]
ComboBox: cbox:
items = sorted(IMAGES.keys())
index = 0
ImageView: img:
image << IMAGES[cbox.selected_item]