我看到可以更改行的背景颜色,但是可以更改单元格的背景颜色吗?
我需要“忙碌”单元格的颜色为红色。
运行如下:
代码就是这样
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()