def to_render_list(self, index, width):
"""
Return list of tuples, where each tuple contains:
column, string content, colour
"""
# import .window for colour indexes
from .window import CPI_GOOD, CPI_ERROR
# status colour
status_color = 0
if 'ok' in self.status:
status_color = CPI_GOOD
elif 'error' in self.status:
status_color = CPI_ERROR
# Gcode string (tree structure prepended
gcode_w = max(0, width - (3 + 20)) # sent, status
# Render List (to return)
render_list = []
if self.tree_chr:
render_list.append((index + 1, self.tree_chr, 0))
render_list.append((index + 2, curses.ACS_HLINE, 0))
gcode_child_w = max(0, gcode_w - 4)
gcode_str = ("{:<%i.%is}" % (gcode_child_w, gcode_child_w)).format(self.gcode)
render_list.append((index + 4, gcode_str, 0))
else:
gcode_str = ("{:<%i.%is}" % (gcode_w, gcode_w)).format(self.gcode)
render_list.append((index, gcode_str, 0))
render_list.append((index + gcode_w + 1, '>' if self.sent else ' ', 0))
render_list.append((index + gcode_w + 3, "{:<20s}".format(self.status), status_color))
return render_list
评论列表
文章目录