use CeoFrame as parent class for TransactionView
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Max Erenberg 2021-09-06 16:48:07 +00:00
parent 40ee927b91
commit 39158676ae
2 changed files with 7 additions and 17 deletions

View File

@ -31,7 +31,7 @@ class CeoFrame(Frame):
def _ceoframe_on_load(self): def _ceoframe_on_load(self):
# We usually don't want _on_load() to be called multiple times # 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: if self._loaded:
return return
self._loaded = True self._loaded = True

View File

@ -1,29 +1,23 @@
from threading import Thread from threading import Thread
from asciimatics.exceptions import NextScene 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 ..operation_strings import descriptions as op_desc
from ..utils import generic_handle_stream_response from ..utils import generic_handle_stream_response
from .CeoFrame import CeoFrame
from .TUIStreamResponseHandler import TUIStreamResponseHandler from .TUIStreamResponseHandler import TUIStreamResponseHandler
class TransactionView(Frame): class TransactionView(CeoFrame):
def __init__(self, screen, width, height, model): def __init__(self, screen, width, height, model):
super().__init__( super().__init__(
screen, screen, height, width, model, 'Transaction',
height, on_load=self._txnview_on_load, title='Running Transaction',
width,
can_scroll=False,
on_load=self._txnview_on_load,
title='Running Transaction',
) )
self._model = model self._model = model
# map operation names to label widgets # map operation names to label widgets
self._labels = model.viewdata['Transaction']['labels'] 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): def _add_buttons(self):
layout = Layout([100]) layout = Layout([100])
@ -44,13 +38,9 @@ class TransactionView(Frame):
self._op_layout.add_widget(Label(''), 2) self._op_layout.add_widget(Label(''), 2)
def _txnview_on_load(self): def _txnview_on_load(self):
if self._loaded:
return
self._loaded = True
d = self._model.viewdata['Transaction'] d = self._model.viewdata['Transaction']
first_time = True
if d['op_layout'] is None: if d['op_layout'] is None:
first_time = True
self._op_layout = Layout([12, 1, 10]) self._op_layout = Layout([12, 1, 10])
self.add_layout(self._op_layout) self.add_layout(self._op_layout)
# store the layouts so that we can re-use them when the screen # store the layouts so that we can re-use them when the screen