<s> """<STR_LIT>""" <EOL> from os . path import join , dirname <EOL> from numpy import sqrt <EOL> from numpy . random import random <EOL> from traits . api import HasTraits , Property , Array <EOL> from traitsui . api import View , Item , TabularEditor <EOL> from traitsui . tabular_adapter import TabularAdapter <EOL> from traitsui . menu import NoButtons <EOL> from pyface . image_resource import ImageResource <EOL> import traitsui . api <EOL> search_path = [ join ( dirname ( traitsui . api . __file__ ) , <EOL> '<STR_LIT>' , '<STR_LIT>' ) ] <EOL> class ArrayAdapter ( TabularAdapter ) : <EOL> columns = [ ( '<STR_LIT:i>' , '<STR_LIT:index>' ) , ( '<STR_LIT:x>' , <NUM_LIT:0> ) , ( '<STR_LIT:y>' , <NUM_LIT:1> ) , ( '<STR_LIT:z>' , <NUM_LIT:2> ) ] <EOL> font = '<STR_LIT>' <EOL> alignment = '<STR_LIT:right>' <EOL> format = '<STR_LIT>' <EOL> index_text = Property <EOL> index_image = Property <EOL> def _get_index_text ( self ) : <EOL> return str ( self . row ) <EOL> def _get_index_image ( self ) : <EOL> x , y , z = self . item <EOL> if sqrt ( ( x - <NUM_LIT:0.5> ) ** <NUM_LIT:2> + ( y - <NUM_LIT:0.5> ) ** <NUM_LIT:2> + ( z - <NUM_LIT:0.5> ) ** <NUM_LIT:2> ) <= <NUM_LIT> : <EOL> return '<STR_LIT>' <EOL> return None <EOL> tabular_editor = TabularEditor ( <EOL> adapter = ArrayAdapter ( ) , <EOL> images = [ ImageResource ( '<STR_LIT>' , search_path = search_path ) ] <EOL> ) <EOL> class ShowArray ( HasTraits ) : <EOL> data = Array <EOL> view = View ( <EOL> Item ( '<STR_LIT:data>' , editor = tabular_editor , show_label = False ) , <EOL> title = '<STR_LIT>' , <EOL> width = <NUM_LIT> , <EOL> height = <NUM_LIT> , <EOL> resizable = True , <EOL> buttons = NoButtons <EOL> ) <EOL> demo = ShowArray ( data = random ( ( <NUM_LIT> , <NUM_LIT:3> ) ) ) </s>
