import os class Grid(): def __init__(self,width,height,cw=3,sep=None): self.grid = [] self.cell_width = cw self.sep = sep self.force_cls = False for i in range(height): self.grid.append([]) for n in range(width): self.grid[i].append(" ") def put(self,y,x,char): #print(y,' ',x) self.grid[y][x] = char def fill(self,char): for i in range(len(self.grid)): for n in range(len(self.grid[i])): self.grid[i][n] = char def update(self): if self.force_cls: os.system("cls") for i in self.grid: line_str = "" for x in i: line_str += x if x == "": x = " " if len(x) < self.cell_width: d = self.cell_width - len(x) for k in range(d): line_str += " " if self.sep != None: line_str += self.sep print line_str#("").join(i)