def default_traits_view(self): view = View( HSplit( VSplit( Item("object_class", editor=self.tree_editor, show_label=False, visible_when="object.show_tree"), Group( Item("search", label="搜索"), Item("search_result_str", show_label=False, editor=ListStrEditor(editable=False, selected_index="search_result_index")), label="Search"), ), Item("current_document", style="custom", show_label=False, editor=CodeEditor(lexer="null", search="top", line = "current_line", mark_lines="mark_lines", mark_color=0xff7777)), id = "tvtkdoc.hsplit" ), width = 700, height = 500, resizable = True, title = "TVTK文档浏览器", id = "tvtkdoc", handler = TVTKDocumentHandler(), ) return view
class DataObjectList(HasTraits): data_objects = List(Str) traits_view = View( Item('data_objects', show_label=False, editor=ListStrEditor())) def _data_objects_default(self): return ['a', 'b', 'c']
class ShoppingListDemo ( HasTraits ): # The list of things to buy at the store: shopping_list = List( Str ) #-- Traits View Definitions ------------------------------------------------ view = View( Item( 'shopping_list', show_label = False, editor = ListStrEditor( title = 'Shopping List', auto_add = True ) ), title = 'Shopping List', width = 0.2, height = 0.5, resizable = True )
except: return 1. return cmp(getNum(x), getNum(y)) filenames_view = View( Group( #Item('directory', style = 'simple'), #Item('pattern', style = 'simple'), Item('filenames', style='custom', editor=ListStrEditor( selected='selected', operations=['insert', 'edit', 'move', 'delete', 'append'], auto_add=True, drag_move=True), height=-100, width=-300), Item('is_reversed', style='simple'), ), Item('from_directory_bttn', show_label=False), # statusbar = [ StatusItem( name = 'error')], resizable=True, ) def filenames_from_list(filenames): """A helper function. Returns a :class:`Filenames` object from a given filenames list
class DLS_Adapter(ListStrAdapter): def get_text_color(self, obj, trait, index): fname = getattr(obj, trait)[index] bad_data = getattr(obj, 'bad_data') if fname in bad_data: return 'red' else: return 'black' dls_filenames_view = View( Item('from_directory_bttn', show_label=False), Group( Item('is_reversed', style='simple'), Item('filenames', editor=ListStrEditor(selected='selected', adapter=DLS_Adapter()), height=-100, width=-300), ), resizable=True, ) class DLS_Filenames(Filenames): bad_data = Set(Str) #good_data = Property(depends_on = 'bad_data,filenames.filenames') #def _get_good_data(self): # return [name for name in self.filenames.filenames if name not in self.bad_data]