Files
scylladb/tools/scyllatop/views/base.py
Yoav Kleinberger 26c0d86401 tools/scyllatop: improved user interface: scrollable views
NOTE: scyllatop now requires the urwid library

previously, if there were more metrics that lines in the terminal
window, the user could not see some of the metrics.  Now the user can
scroll.

As an added bonus, the program will not crash when the window size
changes.

Signed-off-by: Yoav Kleinberger <yoav@scylladb.com>
Message-Id: <1464098832-5755-1-git-send-email-yoav@scylladb.com>
2016-05-26 13:36:28 +03:00

32 lines
835 B
Python

import time
import urwid
class Base(object):
def __init__(self):
self._items = []
self._widgets = {}
self._box = urwid.ListBox(urwid.SimpleFocusListWalker([]))
def widget(self):
return self._box
def writeStatusLine(self, measurements):
line = '*** time: {0}| {1} measurements ***'.format(time.asctime(), len(measurements))
self._items = [line]
def refresh(self):
for i, text in enumerate(self._items):
if i not in self._widgets:
self._widgets[i] = urwid.Button(text)
self._box.body.append(self._widgets[i])
else:
self._widgets[i].set_label(text)
def clearScreen(self):
self._items = []
return
def writeLine(self, thing):
self._items.append(str(thing))