1

I saw that I can change the background color of a row, but is it possible to change the background color of a cell?

I need the color of the "busy" cell to be red.

running looks like this:

Codigo en ejecucion

The code is it:

from tkinter import *
from tkinter.ttk import *
import tkinter.messagebox

class App(Frame):
    def __init__(self, parent):
        Frame.__init__(self, parent)
        self.CreateUI()
        self.LoadTable()
        self.grid(sticky = (N,S,W,E))
        parent.grid_rowconfigure(0, weight = 1)
        parent.grid_columnconfigure(0, weight = 1)

    def CreateUI(self):
        tv = Treeview(self)
        tv['columns'] = ('First', 'Second')
        tv.heading("#0", text=' ', anchor='w')
        tv.column("#0", anchor="w")
        tv.heading('First', text='First')
        tv.column('First', anchor='center', width=100)
        tv.heading('Second', text='Second')
        tv.column('Second', anchor='center', width=100)
        tv.grid(sticky = (N,S,W,E))
        self.treeview = tv
        self.grid_rowconfigure(0, weight = 1)
        self.grid_columnconfigure(0, weight = 1)


    def LoadTable(self):
        agente1 = self.treeview.insert('', 'end', text="Agente1",)
        self.treeview.insert(agente1, 'end', text="Availability", values=('Busy',
                            'Insert'))

def main():
    root = Tk()
    App(root)
    root.mainloop()

if __name__ == '__main__':
    main()
  • Possible duplicate of [How to change the foreground or background colour of a selected cell in tkinter treeview?](https://stackoverflow.com/questions/48358084/how-to-change-the-foreground-or-background-colour-of-a-selected-cell-in-tkinter) – Nouman Oct 03 '18 at 18:34
  • try `.config`. This will allow you to change any option that may be declared on initialization – DarthCadeus Oct 04 '18 at 12:09

0 Answers0