Python - tag_configure()

 
Vista:
sin imagen de perfil
Val: 21
Ha aumentado su posición en 14 puestos en Python (en relación al último mes)
Gráfica de Python

tag_configure()

Publicado por Aitor (6 intervenciones) el 08/06/2021 08:21:03
Hola,

Según el valor que tengo en una fila del Treeview quiero cambiar el color de fondo. Eso antes se hacia con tag_configure() pero por lo que he leído en esta última versión de tkinter no funciona. Es esto correcto? hay alguna otra solución?

Gracias

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import tkinter as tk
import tkinter.ttk as ttk
 
root = tk.Tk()
tree = ttk.Treeview(root)
 
# Inserted at the root, program chooses id:
tree.insert('', 'end', 'foo', text='Foo', tags=['red_fg'])
 
# Inserted underneath an existing node:
tree.insert('foo', 'end', text='Bar', tags=['blue_fg'])
 
# tag's order can be important
tree.tag_configure("red_fg", foreground="red")
tree.tag_configure("blue_fg", foreground="blue")
tree.pack()
root.mainloop()
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder