def __manage_data_listeners(self, list, remove=False): # attach appropriate trait handlers to objects in the list if list is not None: for item in list: item.observe(self._on_contained_trait_changed, match(lambda name, trait: True), remove=remove)
def __manage_column_listeners(self, collist, remove=False): if collist is not None: for col in collist: if isinstance(col, TraitGridColumn): col.observe( self._on_columns_changed, match(lambda name, trait: True), remove=remove, )
def _create_lhs(self, parent): """ Creates the left hand side or top depending on the split. """ self._tree = FileTree(parent, root=os.path.abspath(os.curdir)) self._tree.observe( self._on_tree_anytrait_changed, match(lambda name, ctrait: True) # listen to all traits ) return self._tree.control
def _create_lhs(self, parent): """ Creates the left hand side or top depending on the style. """ self._tree_viewer = FileTreeViewer( parent, input=os.path.abspath(os.curdir), sorter=FileSorter() ) self._tree_viewer.observe( self._on_tree_anytrait_changed, match(lambda name, ctrait: True) # listen to all traits ) return self._tree_viewer.control
def _create_lhs(self, parent): """ Creates the left hand side or top depending on the split. """ model = NodeTreeModel(node_manager=node_manager) model.root = os.path.abspath(os.curdir) self._tree = NodeTree(parent, model=model) self._tree.observe( self._on_tree_anytrait_changed, match(lambda name, ctrait: True) # listen to all traits ) return self._tree.control
def _create_lhs(self, parent): """ Creates the left hand side or top depending on the split. """ self._model = model = TraitGridModel(data=self.trait_data, columns=self.trait_col, row_name_trait="name") self._grid = grid = Grid(parent, model=model) self._grid.observe( self._on_grid_anytrait_changed, match(lambda name, ctrait: True) # listen to all traits ) return grid.control
def dispose(self): """Disposes of the contents of an editor.""" if not (self.factory.share and isinstance(self.value, dict)): self._shell.observe( self.update_object, "command_executed", remove=True, dispatch="ui", ) if self._base_locals is None: self.object.observe( self.update_any, match(self._any_trait_observer), remove=True, dispatch="ui", ) super().dispose()
def init(self, parent): """Finishes initializing the editor by creating the underlying toolkit widget. """ # Moving the import here, since PythonShell is implemented in the # Pyface backend packages, and we want to delay loading this toolkit # specific class until this editor is actually used. from pyface.python_shell import PythonShell locals = None self._base_locals = None value = self.value if self.factory.share and isinstance(value, dict): locals = value self._shell = shell = PythonShell(parent) self.control = shell.control if locals: for item in locals.items(): shell.bind(*item) if locals is None: object = self.object shell.bind("self", object) shell.observe(self.update_object, "command_executed", dispatch="ui") if not isinstance(value, dict): self._any_trait_observer = lambda name, ctrait: True object.observe( self.update_any, match(self._any_trait_observer), dispatch="ui", ) else: self._base_locals = locals = {} for name in self._shell.interpreter().locals.keys(): locals[name] = None # Synchronize any editor events: self.sync_value(self.factory.command_to_execute, "command_to_execute", "from") self.sync_value(self.factory.command_executed, "command_executed", "to") self.set_tooltip()