Python Forum
Tkinter help (color)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tkinter help (color)
#1
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 ? :)
Reply
#2
you don't show enough code.
but what you want to do is similar to:
canvas.itemconfig(myrectangle, fill='green2')
Reply
#3
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')
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question [Tkinter] Can I set background color for each item in tkinter Combobox? water 1 179 Dec-10-2020, 07:48 PM
Last Post: Larz60+
  tkinter | Button color text on Click Maryan 2 337 Oct-09-2020, 08:56 PM
Last Post: Maryan
  Tkinter - How can I change the default Notebook border color? TurboC 4 814 Oct-06-2020, 10:35 PM
Last Post: TurboC
  [tkinter] color change for hovering over button teacher 4 1,376 Jul-04-2020, 06:33 AM
Last Post: teacher
  TKINTER - Change font color for night or day Ayckinn 2 896 May-24-2020, 09:25 PM
Last Post: Ayckinn
  Restoring Tkinter widget background to original color pythonprogrammer 1 811 Dec-16-2019, 04:59 AM
Last Post: woooee
  Make Label Text background (default color) transparent using tkinter in python barry76 1 9,735 Nov-28-2019, 10:19 AM
Last Post: Larz60+
  [Tkinter] color a string of characters in tkinter atlass218 6 3,599 Mar-28-2019, 03:17 PM
Last Post: atlass218
  Insert color in tkinter automatically Dwimmerlaik 4 1,790 Jan-07-2019, 07:10 PM
Last Post: Dwimmerlaik
  [Tkinter] Tkinter Font Color notsolowki 11 38,623 Mar-28-2018, 03:53 AM
Last Post: notsolowki

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020