diff --git a/ceo/tui/CeoFrame.py b/ceo/tui/CeoFrame.py index fb113ba..96778fd 100644 --- a/ceo/tui/CeoFrame.py +++ b/ceo/tui/CeoFrame.py @@ -31,7 +31,7 @@ class CeoFrame(Frame): def _ceoframe_on_load(self): # We usually don't want _on_load() to be called multiple times - # e.g. when switching back to a scene + # e.g. when switching back to a scene, or after calling reset() if self._loaded: return self._loaded = True diff --git a/ceo/tui/TransactionView.py b/ceo/tui/TransactionView.py index 26f6527..ed7809d 100644 --- a/ceo/tui/TransactionView.py +++ b/ceo/tui/TransactionView.py @@ -1,29 +1,23 @@ from threading import Thread from asciimatics.exceptions import NextScene -from asciimatics.widgets import Frame, Layout, Button, Divider, Label +from asciimatics.widgets import Layout, Button, Divider, Label from ..operation_strings import descriptions as op_desc from ..utils import generic_handle_stream_response +from .CeoFrame import CeoFrame from .TUIStreamResponseHandler import TUIStreamResponseHandler -class TransactionView(Frame): +class TransactionView(CeoFrame): def __init__(self, screen, width, height, model): super().__init__( - screen, - height, - width, - can_scroll=False, - on_load=self._txnview_on_load, - title='Running Transaction', + screen, height, width, model, 'Transaction', + on_load=self._txnview_on_load, title='Running Transaction', ) self._model = model # map operation names to label widgets self._labels = model.viewdata['Transaction']['labels'] - # this is an ugly hack to get around the fact that _on_load() - # will be called again when we reset() in enable_next_btn. - self._loaded = False def _add_buttons(self): layout = Layout([100]) @@ -44,13 +38,9 @@ class TransactionView(Frame): self._op_layout.add_widget(Label(''), 2) def _txnview_on_load(self): - if self._loaded: - return - self._loaded = True - d = self._model.viewdata['Transaction'] - first_time = True if d['op_layout'] is None: + first_time = True self._op_layout = Layout([12, 1, 10]) self.add_layout(self._op_layout) # store the layouts so that we can re-use them when the screen