Python Forum

Full Version: Tkinter help (color)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
Thanks to Tkinter, I want to make a green rectangle but even I write " fill='green2' ", my rectangle still black.

Extract of my code :
maree.create_rectangle(i,j,i+1,j+1,fill = 'green2')
I have tried this :

Color='green2'
maree.create_rectangle(i,j,i+1,j+1,fill = Color)
But the rectangle still black.

Can anyone help me please ? :)
you don't show enough code.
but what you want to do is similar to:
canvas.itemconfig(myrectangle, fill='green2')
What I want to do is to colorate an area thanks to a matrix :

    
maree = Canvas(tab,width = n, height = m-1, background = 'dodger blue')
    
    for i in range(n):
        for j in range(m):
            if C[i][j] == 2:
                maree.create_rectangle(i,j,i+1,j+1,fill = 'green2')
            if C[i][j] == 1 :
                maree.create_rectangle(i,j,i+1,j+1,fill = 'black')