from asciimatics.exceptions import NextScene from asciimatics.widgets import Layout, Label from .CeoFrame import CeoFrame class ErrorView(CeoFrame): def __init__(self, screen, width, height, model): super().__init__( screen, height, width, model, 'Error', on_load=self._errorview_on_load, title='Error', ) def _errorview_on_load(self): layout = Layout([1, 10], fill_frame=True) self.add_layout(layout) for _ in range(2): layout.add_widget(Label(''), 1) layout.add_widget(Label('An error occurred:'), 1) layout.add_widget(Label(''), 1) for line in self._model.error_message.splitlines(): layout.add_widget(Label(line), 1) self.add_buttons(on_next_excl=self._next) self.fix() def _next(self): self._model.reset() raise NextScene('Welcome')