0
from tkinter import *
root = Tk()

height = 8
width = 8
for c in range(height): #Rows
    for d in range(width): #Columns
        b = Entry(root, text="")
        b.grid(row=c, column=d)

mainloop()

I have created a table in Python using tkinter but as part of my project I need the cells to be separate colours. I need each individual cell to be a separate colour from the rest and I am a bit stuck because usually I use HTML but my task is in python.

Does anyone have any ideas in how I can do this?

1 Answers1

0
from tkinter import *
import random

root = Tk()

height = 8
width = 8

for r in range(height):
    for c in range(width):
        colour = "#%06x" % random.randint(0, 0xFFFFFF)
        b = Entry(root, text = '', bg = colour)
        b.grid(row = r, column = c)

mainloop()
Luke.py
  • 965
  • 8
  • 17