-1

i building with tkinter a tree view that display me a lot of data and i want when in column 5 there is the word "free" the color background of the row will be yellow how can i do that? ty for your help

def Read():
    Database()
    cursor.execute("SELECT * FROM `tbl_Employees")
    fetch = cursor.fetchall()
    for data in fetch:
        tree.insert('', 'end', values=(data[1], data[2], data[3], data[4], data[5], data[6]))
    cursor.close()
    conn.close()
    txt_result.config(text="Successfully read the data from database", fg="green")
    txt_result.after(2000, clear_txt)

i tried to insert

if data[5] == 'free':
   ....??

but i dont know what the right command in the if block that going to do what i want

jizhihaoSAMA
  • 12,336
  • 9
  • 27
  • 49
  • Does this answer your question? [how-to-change-the-foreground-or-background-colour-of-a-selected-cell-in-tkinter](https://stackoverflow.com/questions/48358084) – stovfl May 26 '20 at 10:44

1 Answers1

0
 def Read():
    Database()
    cursor.execute("SELECT * FROM `tbl_Employees")
    fetch = cursor.fetchall()
    for data in fetch:
        tree.insert('', 'end', values=(data[1], data[2], data[3], data[4], data[5],))
    cursor.close()
    conn.close()
    txt_result.config(text="Successfully read the data from database", fg="green")
    txt_result.after(2000, clear_txt)
Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685