def __animate_fired(self): try: self.handler.animate(self._number_of_runs, ui=True, update_all_scenes=self._update_all_scenes) except RuntimeError as exception: message_dialog = MessageDialog() message_dialog.error(exception.message)
def __add_to_scene_fired(self): added_source_indices = [] # sources that are sucessfully added err_messages = [] # keep all error messages for display at once # add source one by one for index, source in enumerate(self._pending_engine_sources): try: add_source_and_modules_to_scene(self.mayavi_engine, source) except Exception as exception: message_format = ("{err_type} (while adding {source}):\n" " {message}") text = message_format.format(err_type=type(exception).__name__, message=exception.message, source=source.dataset) err_messages.append(text) else: added_source_indices.append(index) # Display error messages if there is any if len(err_messages) > 0: message_dialog = MessageDialog() message_dialog.error("\n".join(err_messages)) # Keep the sources failed to be added for index in added_source_indices[::-1]: self._pending_engine_sources.pop(index)
def __add_dataset_fired(self): if self.engine is None: message_dialog = MessageDialog() message_dialog.error("No engine is selected") return if len(self.engine.get_dataset_names()) == 0: message_dialog = MessageDialog() message_dialog.error("The engine has no dataset") return source = EngineSource(engine=self.engine) source.engine_name = self.engine_name source._dataset_changed() # Default trait view of EngineSource source_view = source.trait_view() # Add handler for appending to the list of pending sources source_view.handler = PendingEngineSourceHandler() # Add buttons AddToPending = Action(name="Confirm", action="append_list") source_view.buttons = [AddToPending, "Cancel"] return self.edit_traits(view=source_view, context={"object": source, "manager": self})
def _setup_run_parameters(self): CM = self.engine.CM # For interacting with the engine if CUBA.TIME_STEP in CM: self.time_step = CM[CUBA.TIME_STEP] else: text = "engine.CM[TIME_STEP] is not found." message_dialog = MessageDialog() message_dialog.error(text) if CUBA.NUMBER_OF_TIME_STEPS in CM: value = CM[CUBA.NUMBER_OF_TIME_STEPS] self.number_of_time_steps = value else: text = "engine.CM[NUMBER_OF_TIME_STEPS] is not found." message_dialog = MessageDialog() message_dialog.error(text)