+ class MapWidget(urwid.Widget):
+ _sizing = frozenset(['box'])
+ text = ['']
+
+ def render(self, size, focus=False):
+ maxcol, maxrow = size
+ content = []
+ for y in range(len(self.text)):
+ if y < maxrow:
+ line = self.text[y]
+ if len(line) < maxcol:
+ line = line + '0' * (maxcol - len(line))
+ else:
+ line = line[:maxcol]
+ content += [line.encode('utf-8')]
+ padding_y = maxrow - len(content)
+ if padding_y > 0:
+ for y in range(padding_y):
+ content += ['0'.encode('utf-8') * maxcol]
+ return urwid.TextCanvas(content)
+