I've been trying to make a minesweeper board on Spyder, but I've encountered a problem with my pandas data frame. The values in the grid are colored (using colorama).
the program:
import numpy
import pandas
from colorama import Fore
def color(col, mot):
if col=="red":
mot = Fore.RED str(mot) Fore.RESET
if col=="white":
mot = Fore.WHITE str(mot) Fore.RESET
if col =="blue":
mot = Fore.BLUE str(mot) Fore.RESET
if col == "green":
mot = Fore.GREEN str(mot) Fore.RESET
return mot
grid = [['\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m'], ['\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m'], ['\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m'], ['\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m'], ['\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m'], ['\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m'], ['\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m'], ['\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m'], ['\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m'], ['\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m']]
x = numpy.array(grid)
row_labels = ['L1', 'L2', 'L3', 'L4','L5','L6','L7','L8','L9','L10']
column_labels = [color("white",'C1'), color("white",'C2'), color("white",'C3'), color("white",'C4'),color("white",'C5'),color("white",'C6'),color("white",'C7'),color("white",'C8'),color("white",'C9'),color("white",'C10')]
df = pandas.DataFrame(x,columns=column_labels, index=row_labels)
print("-------------" color("red", "Demineur") "-------------")
print()
print(df)
print()
print("----------------------------------")