How does one go about changing the selected text color in treeview, I can't seem to find much on the subject.
Here is what I have tried but the color doesn't change to red as I would like, it stays blue.
from tkinter import *
from tkinter.ttk import Treeview, Style
class App(Frame):
def __init__(self, parent):
super().__init__()
self.container = Frame.__init__(self, parent)
style = Style()
self.tv = None
self.tree()
style.configure('Treeview', selectbackground='red')
def tree(self):
tv = self.tv = Treeview(self.container)
tv.grid(sticky='NSEW')
tv.insert('', '0', 'item1', text='Item 1')
tv.insert('', '1', 'item2', text='Item 2')
tv.insert('', '2', 'item3', text='Item 3')
tv.insert('item1', '0', 'python1', text='Python 1')
tv.insert('item1', '1', 'python2', text='Python 2')
tv.insert('python1', '0', 'sub1', text='Sub item 1')
tv.insert('python1', '1', 'sub2', text='Sub item 2')
def main():
root = Tk()
root.grid_rowconfigure(0, weight=1)
root.grid_columnconfigure(0, weight=1)
App(root)
root.mainloop()
if __name__ == '__main__':
main()